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(); }
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(); }