Beispiel #1
0
 public void AddSession(Socket s, TcpServer server)
 {
     lock (_lock)
     {
         InternalSession session = new InternalSession(server, s);
         mDicSession[s] = session;
     }
 }
Beispiel #2
0
        public InternalSession FindSessionToSocket(Socket s)
        {
            InternalSession session = null;

            if (mDicSession.ContainsKey(s))
            {
                session = mDicSession[s];
            }
            return(session);
        }
Beispiel #3
0
 public void RemoveSession(Socket s)
 {
     lock (_lock)
     {
         if (mDicSession.ContainsKey(s))
         {
             InternalSession session = mDicSession[s];
             mDicSession.Remove(s);
         }
     }
 }
Beispiel #4
0
 public void ReceiveData(Socket s, byte[] data, int nSize)
 {
     lock (_lock)
     {
         if (mDicSession.ContainsKey(s))
         {
             InternalSession session = mDicSession[s];
             byte[]          msg     = new byte[nSize];
             Buffer.BlockCopy(data, 0, msg, 0, nSize);
             session.GetPacket().ProcessNetMsg(msg);
             session.SetLastTime(System.Environment.TickCount);
         }
     }
 }