コード例 #1
0
        public void ReadBytes()
        {
            if (currentContainerToFill == null)
            {
                if (availableData.Count < NumberOfReservedBytesForMessageLength)
                    return;
                currentContainerToFill = new MessageData(ReadLength());
            }

            currentContainerToFill.ReadData(availableData);
            if (currentContainerToFill.IsDataComplete)
                TriggerObjectFinishedAndResetCurrentContainer();

            if (availableData.Count > 0)
                ReadBytes();
        }
コード例 #2
0
 private void TriggerObjectFinishedAndResetCurrentContainer()
 {
     if (ObjectFinished != null)
         ObjectFinished(currentContainerToFill);
     currentContainerToFill = null;
 }
コード例 #3
0
 public DataCollector()
 {
     availableData = new Queue<byte>();
     currentContainerToFill = null;
 }
コード例 #4
0
ファイル: TcpSocket.cs プロジェクト: hillwhite/DeltaEngine
 private void OnObjectFinished(MessageData dataContainer)
 {
     using (var dataStream = new MemoryStream(dataContainer.Data))
     using (var dataReader = new BinaryReader(dataStream))
     {
         BinaryData receivedMessage = GetReceivedMessage(dataReader);
         if (DataReceived != null)
             DataReceived(this, receivedMessage);
     }
 }