private void OnReceiveCallback(IAsyncResult ar) { try { int length = _stream.EndRead(ar); byte[] data = new byte[length]; Buffer.BlockCopy(_buffer, 0, data, 0, length); if (data.Length >= 2) { handlePacket(data); } new Thread(new ThreadStart(BeginRead)).Start(); } catch { GameServerManager.GetInstance().RemoveClient(this); Log.Error("Lost connection from gameserver"); } }
private void Accept(TcpClient tcpClient) { GameServerManager.GetInstance().AddClient(tcpClient); }
private void close() { GameServerManager.GetInstance().RemoveClient(this); this._stream.Dispose(); }