private ResponseMessage Decode(Stream responseStream) { ByteBuffer buffer = ByteBuffer.Allocate(512); byte[] tempBytes = new byte[256]; while (true) { int readLen = responseStream.Read(tempBytes, 0, tempBytes.Length); if (readLen <= 0) { break; } buffer.WriteBytes(tempBytes); } ResponseMessage responseMessage = new ResponseMessage(); responseMessage.MessageId = buffer.ReadInt(); responseMessage.StatusCode = HttpStatusCode.OK; TBase message = ThriftMessageHelper.GetResponseMessage(responseMessage.MessageId); if (message == null) { Debuger.LogError("don't support response messageId:" + responseMessage.MessageId); return(null); } byte[] headerBytes = new byte[buffer.ReadInt()]; buffer.ReadBytes(headerBytes, 0, headerBytes.Length); byte[] messageBytes = new byte[buffer.ReadInt()]; buffer.ReadBytes(messageBytes, 0, messageBytes.Length); byte[] eventListBytes = new byte[buffer.ReadInt()]; buffer.ReadBytes(eventListBytes, 0, eventListBytes.Length); responseMessage.Header = new Header(); ThriftSerialize.DeSerialize(responseMessage.Header, headerBytes); responseMessage.Message = message; ThriftSerialize.DeSerialize(message, messageBytes); responseMessage.EventList = new MEventList(); ThriftSerialize.DeSerialize(responseMessage.EventList, eventListBytes); return(responseMessage); }
public object Decode(ByteBuffer buffer) { byte[] bytes = new byte[buffer.ReadInt()]; buffer.ReadBytes(bytes, 0, bytes.Length); return bytes; }