예제 #1
0
 public void OnBroken(Acceptor acceptor, Session session)
 {
     lock (acceptor.sessionsLock)
     {
         long id = session.Id;
         if (acceptor.sessions.ContainsKey(id))
         {
             if (acceptor.removeQueue == null)
             {
                 acceptor.removeQueue = new Queue <Session>();
             }
             acceptor.removeQueue.Enqueue(session);
         }
     }
     session.State = Session.STATE_CLOSED;
     session.Channel.ForceDisconnect();
 }
예제 #2
0
 public void OnConnected(Acceptor acceptor, Session session)
 {
     runtime = DateTime.Now;
     lock (acceptor.sessionsLock)
     {
         session.State         = Session.STATE_OPEN;
         session.LastReadTime  = runtime;
         session.LastWriteTime = runtime;
         long id = session.Id;
         if (sessions.ContainsKey(id))
         {
             sessions[id] = session;
         }
         else
         {
             sessions.Add(id, session);
         }
     }
     session.Start();
 }