void OnReceivedInternal(MemoryStream ms) { BinaryReader br = new BinaryReader(ms); byte[] message = br.ReadBytes((int)(ms.Length - ms.Position)); br.Close(); ms.Close(); ms.Dispose(); NetBuffer temp = new NetBuffer(message); ushort cmd = temp.ReadShort(); byte[] buf = temp.ReadRemaining(); SocketClientManager.AddEvent(cmd.ToString(), new NetBuffer(buf)); }