private ResponseMsg getResponse() { var ms = m_MemStream; var nets = m_Client.GetStream(); var msb = ms.GetBuffer(); var frameBegin = Consts.PACKET_DELIMITER_LENGTH; SyncBinding.socketRead(nets, msb, 0, frameBegin); var size = msb.ReadBEInt32(); if (size < 1 || size > Binding.MaxMsgSize) { Instrumentation.ClientGotOverMaxMsgSizeErrorEvent.Happened(App.Instrumentation, Node); // There is no recovery here - close the channel! throw new MessageSizeException(size, Binding.MaxMsgSize, "getResponse()", closeChannel: true); } ms.SetLength(frameBegin + size); //this may invalidate msb SyncBinding.socketRead(nets, ms.GetBuffer(), frameBegin, size); var arrivalTime = Binding.StatTimeTicks; ms.Position = Consts.PACKET_DELIMITER_LENGTH; ResponseMsg result = null; WireFrame frame; try { try { frame = new WireFrame(ms); result = DoDecodeResponse(frame, ms); } catch { Instrumentation.ClientDeserializationErrorEvent.Happened(App.Instrumentation, Node); throw; } } finally { Binding.DumpMsg(false, result, ms.GetBuffer(), 0, size + Consts.PACKET_DELIMITER_LENGTH); } result.__SetArrivalTimeStampTicks(arrivalTime); stat_MsgReceived(); stat_BytesReceived(size); return(result); }
private ResponseMsg deserialize(ref WireMsg wmsg) { var chunk = wmsg.Data; chunk.Position = sizeof(int); WireFrame frame; ResponseMsg result = null; var arrivalTime = Binding.StatTimeTicks; object received = null; try { try { frame = new WireFrame(chunk); wmsg.Frame = frame; received = Binding.Serializer.Deserialize(chunk); } catch { Instrumentation.ClientDeserializationErrorEvent.Happened(Node); throw; } if (received == null) { throw new ProtocolException(StringConsts.GLUE_UNEXPECTED_MSG_ERROR + "ResponseMsg. Got <null>"); } result = received as ResponseMsg; if (result == null) { throw new ProtocolException(StringConsts.GLUE_UNEXPECTED_MSG_ERROR + "ResponseMsg"); } stat_MsgReceived(); stat_BytesReceived(chunk.Position); } catch { stat_Errors(); throw; } finally { Binding.DumpMsg(false, received as Msg, chunk.GetBuffer(), 0, (int)chunk.Position); } result.__SetArrivalTimeStampTicks(arrivalTime); return(result); }