feat(Core/Compression): Move packets compression from map to network thread (#18602)

* feat(Code/Compression): Move packets compression from map to network thread.

* Code style fix

* Remove unicode letter
This commit is contained in:
Anton Popovichenko
2024-03-28 12:57:29 +01:00
committed by GitHub
parent 3ff8de2086
commit 73340b94e3
14 changed files with 122 additions and 118 deletions

View File

@@ -30,17 +30,21 @@
using boost::asio::ip::tcp;
class EncryptablePacket : public WorldPacket
class EncryptableAndCompressiblePacket : public WorldPacket
{
public:
EncryptablePacket(WorldPacket const& packet, bool encrypt) : WorldPacket(packet), _encrypt(encrypt)
EncryptableAndCompressiblePacket(WorldPacket const& packet, bool encrypt) : WorldPacket(packet), _encrypt(encrypt)
{
SocketQueueLink.store(nullptr, std::memory_order_relaxed);
}
bool NeedsEncryption() const { return _encrypt; }
std::atomic<EncryptablePacket*> SocketQueueLink;
bool NeedsCompression() const { return GetOpcode() == SMSG_UPDATE_OBJECT && size() > 100; }
void CompressIfNeeded();
std::atomic<EncryptableAndCompressiblePacket*> SocketQueueLink;
private:
bool _encrypt;
@@ -125,7 +129,7 @@ private:
MessageBuffer _headerBuffer;
MessageBuffer _packetBuffer;
MPSCQueue<EncryptablePacket, &EncryptablePacket::SocketQueueLink> _bufferQueue;
MPSCQueue<EncryptableAndCompressiblePacket, &EncryptableAndCompressiblePacket::SocketQueueLink> _bufferQueue;
std::size_t _sendBufferSize;
QueryCallbackProcessor _queryProcessor;