private void SendCompressedPacket(Stream stream, byte[] buffer, bool newCommand)
        {
            using (var mem = new MemoryStream())
            {
                // Let the previous packet handler finalize first.
                _handler.SendPacket(mem, buffer, newCommand);
                buffer = mem.ToArray();
            }

            var compressed = Compress(buffer);

            var header = new byte[7];

            WriteInt3(header, 0, compressed.Length);
            header[3] = _sequence++;
            WriteInt3(header, 4, buffer.Length);

            stream.Write(header, 0, 7);
            stream.Write(compressed, 0, compressed.Length);
        }