/// <summary> /// 解码从服务器收到的消息(暂时不做加密和解密处理),协议格式:total(4) + seqId(4) + messageId(2) + errorCode(4) + crc(8) + body /// </summary> /// <param name="byteBuf"></param> /// <returns></returns> public IGameMessage DecodeGameMessage(ByteBuf byteBuf) { int total = byteBuf.ReadInt(); int seqId = byteBuf.ReadInt(); int messageUniqueId = byteBuf.ReadInt(); int errorCode = byteBuf.ReadInt(); byte[] body = null; if (errorCode == 0) { int bodyLen = byteBuf.ReadableBytes(); body = new byte[bodyLen]; byteBuf.ReadBytes(body); } IGameMessage gameMessage = this.NewGameMessage(messageUniqueId); if (gameMessage != null) { gameMessage.DecodeBody(body); } return(gameMessage); }