public void AddSession(Socket s, TcpServer server) { lock (_lock) { InternalSession session = new InternalSession(server, s); mDicSession[s] = session; } }
public InternalSession FindSessionToSocket(Socket s) { InternalSession session = null; if (mDicSession.ContainsKey(s)) { session = mDicSession[s]; } return(session); }
public void RemoveSession(Socket s) { lock (_lock) { if (mDicSession.ContainsKey(s)) { InternalSession session = mDicSession[s]; mDicSession.Remove(s); } } }
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); } } }