public bool CanUnFrameData(IBufferReader readerBuffer) { if (_packageLength == -1) { return(readerBuffer.TryRead(_headerSize)); } else { return(readerBuffer.TryRead(_packageLength)); } }
public void UnFrameData(IBufferReader readerBuffer) { if (_packageLength == -1) { if (readerBuffer.TryRead(_headerSize)) { ReadHeader(readerBuffer); ReadData(readerBuffer); } } else { ReadData(readerBuffer); } }
private void ReadData(IBufferReader readerBuffer) { if (readerBuffer.TryRead(_packageLength)) { var data = readerBuffer.ReadResult(_packageLength); if (_receivedHandler != null) { try { _receivedHandler(data); } catch (Exception ex) { Log <LengthPrefixMessageFramer> .Error(ex, "Handle received message fail."); } } _packageLength = -1; } }