Beispiel #1
0
        private void TryParsingReceivedData(ConcurrentQueue <ReceivedData> receiveQueue)
        {
            if (!EnterParsing())
            {
                return;
            }

            try
            {
                var dataList    = new List <ReceivedData>(receiveQueue.Count);
                var segmentList = new List <ArraySegment <byte> >();

                ReceivedData data;
                while (receiveQueue.TryDequeue(out data))
                {
                    dataList.Add(data);
                    segmentList.Add(new ArraySegment <byte>(data.Buf.Array, data.Buf.Offset, data.DataLen));
                }

                _framer.UnFrameData(segmentList);

                for (int i = 0, n = dataList.Count; i < n; ++i)
                {
                    _receiveDataBufferPool.Return(dataList[i].Buf.Array);
                }
            }
            finally
            {
                ExitParsing();
            }
        }
Beispiel #2
0
        private void TryParsingReceivedData()
        {
            if (!EnterParsing())
            {
                return;
            }

            try
            {
                var dataList    = new List <ReceivedData>(_receiveQueue.Count);
                var segmentList = new List <ArraySegment <byte> >();

                ReceivedData data;
                while (_receiveQueue.TryDequeue(out data))
                {
                    dataList.Add(data);
                    segmentList.Add(new ArraySegment <byte>(data.Buf.Array, data.Buf.Offset, data.DataLen));
                }

                _framer.UnFrameData(segmentList);

                for (int i = 0, n = dataList.Count; i < n; ++i)
                {
                    _receiveDataBufferPool.Return(dataList[i].Buf.Array);
                }
            }
            catch (Exception ex)
            {
                _logger.Error("Parsing received data error.", ex);
            }
            finally
            {
                ExitParsing();
            }
        }
Beispiel #3
0
        private void OnRawDataReceived(ITcpConnection connection, IEnumerable <ArraySegment <byte> > data)
        {
            try {
                _framer.UnFrameData(data);
            } catch (PackageFramingException exc) {
                Log.InfoException(exc, "Invalid TCP frame received.");
                Close("Invalid TCP frame received.");
                return;
            }

            connection.ReceiveAsync(OnRawDataReceived);
        }
Beispiel #4
0
 private void OnRawDataReceived(ITcpConnection connection, IEnumerable <ArraySegment <byte> > data)
 {
     try
     {
         _framer.UnFrameData(data);
     }
     catch (PackageFramingException exc)
     {
         CloseConnectionOnError(string.Format("Invalid TCP frame received. Error: {0}.", exc.Message));
         return;
     }
     _tcpConnection.ReceiveAsync(OnRawDataReceived);
 }
Beispiel #5
0
 private void OnRawDataReceived(ITcpConnection connection, IEnumerable <ArraySegment <byte> > data)
 {
     try
     {
         _messageFramer.UnFrameData(data);
     }
     catch (PackageFramingException ex)
     {
         _logger.Error("Unframe data has exception.", ex);
         return;
     }
     connection.ReceiveAsync(OnRawDataReceived);
 }
        private void TryParsingReceived()
        {
            if (!EnterParsing())
            {
                return;
            }

            try
            {
                while (_messageFramer.CanUnFrameData(_receiveBuufferPipeline.Reader))
                {
                    _messageFramer.UnFrameData(_receiveBuufferPipeline.Reader);
                }
            }
            catch (Exception ex)
            {
                CloseInternal(SocketError.Shutdown, "Parsing received data error.", ex);
                return;
            }
            finally
            {
                ExitParsing();
            }
        }
Beispiel #7
0
 private void OnRawDataReceived(ITcpConnection connection, IEnumerable <ArraySegment <byte> > data)
 {
     _framer.UnFrameData(data);
     connection.ReceiveAsync(OnRawDataReceived);
 }