Exemple #1
0
        protected void AcceptCompleted(IAsyncResult result)
        {
            RCAsyncState state = (RCAsyncState)result.AsyncState;

            try
            {
                Socket client = _listener.EndAccept(result);
                RCBot  bot    = state.Runner.GetBot(state.Closure.Bot);
                // long handle = state.Closure.Bot.New ();
                long             handle  = bot.New();
                TcpServerSession session = new TcpServerSession(state,
                                                                this,
                                                                client,
                                                                _inbox,
                                                                handle);
                lock (_lock)
                {
                    _clients.Add(handle, session);
                }
                session.Start();
                _listener.BeginAccept(new AsyncCallback(AcceptCompleted), state);
            }
            catch (Exception ex)
            {
                state.Runner.Report(state.Closure, ex);
            }
        }
Exemple #2
0
        public long NextId(TcpServerSession session)
        {
            long id;

            lock (_lock)
            {
                id = _id++;
                _requests.Add(id, session);
            }
            return(id);
        }