Example #1
0
 public bool CanUnFrameData(IBufferReader readerBuffer)
 {
     if (_packageLength == -1)
     {
         return(readerBuffer.TryRead(_headerSize));
     }
     else
     {
         return(readerBuffer.TryRead(_packageLength));
     }
 }
Example #2
0
 public void UnFrameData(IBufferReader readerBuffer)
 {
     if (_packageLength == -1)
     {
         if (readerBuffer.TryRead(_headerSize))
         {
             ReadHeader(readerBuffer);
             ReadData(readerBuffer);
         }
     }
     else
     {
         ReadData(readerBuffer);
     }
 }
Example #3
0
 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;
     }
 }