Added decompression/compression of packets. Cleaned up handshaking.

This commit is contained in:
Filip Maj 2016-08-24 15:41:54 -04:00
parent 4aae16e458
commit 364ab40b3f
8 changed files with 123 additions and 43 deletions

View file

@ -5,6 +5,7 @@ using System.IO;
using System.Runtime.InteropServices;
using NLog;
using NLog.Targets;
using Ionic.Zlib;
namespace FFXIVClassic.Common
{
@ -346,6 +347,28 @@ namespace FFXIVClassic.Common
}
}
public static unsafe void DecompressPacket(ref BasePacket packet)
{
using (var compressedStream = new MemoryStream(packet.data))
using (var zipStream = new ZlibStream(compressedStream, Ionic.Zlib.CompressionMode.Decompress))
using (var resultStream = new MemoryStream())
{
zipStream.CopyTo(resultStream);
packet.data = resultStream.ToArray();
}
}
public static unsafe void CompressPacket(ref BasePacket packet)
{
using (var compressedStream = new MemoryStream(packet.data))
using (var zipStream = new ZlibStream(compressedStream, Ionic.Zlib.CompressionMode.Compress))
using (var resultStream = new MemoryStream())
{
zipStream.CopyTo(resultStream);
packet.data = resultStream.ToArray();
}
}
#endregion
}