public override void OnMessage(USocket us, ByteBuf bb) { bb.ReaderIndex(us.getProtocol().HeaderLen()); short cmd = bb.ReadShort(); byte[] bs = bb.GetRaw(); using (var stream = new MemoryStream(bs, bb.ReaderIndex(), bb.ReadableBytes())) { object obj = protocol.DecodeMessage(MessageQueueHandler.GetProtocolType(cmd), stream); MessageQueueHandler.PushQueue(cmd, obj); } }
public override void OnMessage(USocket us, ByteBuf bb) { bb.ReaderIndex(us.getProtocol().HeaderLen()); int cmd = bb.ReadInt(); Debug.Log("Socket Recive Message ID: " + cmd); byte[] bs = bb.GetRaw(); using (var stream = new MemoryStream(bs, bb.ReaderIndex(), bb.ReadableBytes())) { if (MessageQueueHandler.GetProtocolType(cmd) != null) { object obj = protocol.DecodeMessage(MessageQueueHandler.GetProtocolType(cmd), stream); MessageQueueHandler.PushQueue((short)cmd, obj); } } }