Ejemplo n.º 1
0
        private async Task DispatchIncomingPacket()
        {
            using (var bufferScope = _bufferPool.CreateScope())
            {
                var packet = _uncompressedPacketObjectPool.Get();
                try
                {
                    if (_useCompression)
                    {
                        var compressedPacket = await CompressedPacket.DeserializeAsync(_remoteStream, null);

                        packet = PacketCompress.Decompress(compressedPacket, bufferScope, 0, packet);
                    }
                    else
                    {
                        packet = await UncompressedPacket.DeserializeAsync(_remoteStream, bufferScope, packet);
                    }

                    await DispatchIncomingPacket(packet);
                }
                finally
                {
                    _uncompressedPacketObjectPool.Return(packet);
                }
            }
        }
Ejemplo n.º 2
0
        private async Task DispatchIncomingPacket()
        {
            UncompressedPacket packet;

            if (_useCompression)
            {
                var compressedPacket = await CompressedPacket.DeserializeAsync(_remoteStream);

                packet = PacketCompress.Decompress(ref compressedPacket);
            }
            else
            {
                packet = await UncompressedPacket.DeserializeAsync(_remoteStream);
            }
            await DispatchIncomingPacket(packet);
        }