Пример #1
0
        public async IAsyncEnumerable <Packet> GetPackets()
        {
            var networkStream = new NetworkStream(_socket, false);

            byte[] streamBuffer = new byte[BufferSize];

            var streamSize = await networkStream.ReadAsync(streamBuffer, 0, streamBuffer.Length);

            Array.Resize(ref streamBuffer, streamSize);

            await foreach (var packet in _packetConverter.StreamFromBytes <Packet>(streamBuffer))
            {
                yield return(packet);
            }
        }