예제 #1
0
        /// <summary>
        /// Handles new connections.
        /// </summary>
        /// <param name="socket">The connection socket.</param>
        protected virtual void HandleConnection(Socket socket)
        {
            ToffeeSession session = new ToffeeSession(SessionManager, socket);

            SessionManager.NewSession(session);
            Log?.Info("Began new session. (id: {0})", session.SessionId);
        }
예제 #2
0
        public void SessionDisconnected(ToffeeSession session)
        {
            if (session.SessionId >= UniqueIdentifiers.Count)
            {
                return;
            }
            UniqueIdentifiers[session.SessionId] = false;
            _Sessions.Remove(session);
            SessionLookup.Remove(session.SessionId);

            if (Server.Log != null)
            {
                Server.Log.Info("Session {0} disconnected.", session.SessionId);
            }
            Server.SessionDisconnected();
        }
예제 #3
0
 public void NewSession(ToffeeSession session)
 {
     session.SessionId = GetUniqueIdentifier();
     _Sessions.Add(session);
     SessionLookup.Add(session.SessionId, session);
 }
예제 #4
0
 /// <summary>
 /// Handles recieved packets.
 /// </summary>
 /// <param name="session">The session that received the packet.</param>
 /// <param name="packet">The packet data that was received.</param>
 public virtual void HandlePacket(ToffeeSession session, byte[] packet)
 {
     Log?.Warning("Handle packet. (This should be overridden!)");
 }