mirror of
https://bitbucket.org/Ioncannon/project-meteor-server.git
synced 2025-06-08 13:34:38 +02:00
Added decompression/compression of packets. Cleaned up handshaking.
This commit is contained in:
parent
4aae16e458
commit
364ab40b3f
8 changed files with 123 additions and 43 deletions
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue