AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
EncryptableAndCompressiblePacket Class Reference

#include "WorldSocket.h"

Inheritance diagram for EncryptableAndCompressiblePacket:
WorldPacket ByteBuffer

Public Member Functions

 EncryptableAndCompressiblePacket (WorldPacket const &packet, bool encrypt)
 
bool NeedsEncryption () const
 
bool NeedsCompression () const
 
void CompressIfNeeded ()
 
- Public Member Functions inherited from WorldPacket
 WorldPacket ()
 
 WorldPacket (uint16 opcode, std::size_t res=200)
 
 WorldPacket (WorldPacket &&packet) noexcept
 
 WorldPacket (WorldPacket &&packet, TimePoint receivedTime)
 
 WorldPacket (WorldPacket const &right)
 
WorldPacketoperator= (WorldPacket const &right)
 
WorldPacketoperator= (WorldPacket &&right) noexcept
 
 WorldPacket (uint16 opcode, MessageBuffer &&buffer)
 
void Initialize (uint16 opcode, std::size_t newres=200)
 
uint16 GetOpcode () const
 
void SetOpcode (uint16 opcode)
 
TimePoint GetReceivedTime () const
 
- Public Member Functions inherited from ByteBuffer
 ByteBuffer ()
 
 ByteBuffer (std::size_t reserve)
 
 ByteBuffer (ByteBuffer &&buf) noexcept
 
 ByteBuffer (ByteBuffer const &right)=default
 
 ByteBuffer (MessageBuffer &&buffer)
 
virtual ~ByteBuffer ()=default
 
ByteBufferoperator= (ByteBuffer const &right)
 
ByteBufferoperator= (ByteBuffer &&right) noexcept
 
void clear ()
 
template<typename T >
void append (T value)
 
template<typename T >
void put (std::size_t pos, T value)
 
ByteBufferoperator<< (bool value)
 
ByteBufferoperator<< (uint8 value)
 
ByteBufferoperator<< (uint16 value)
 
ByteBufferoperator<< (uint32 value)
 
ByteBufferoperator<< (uint64 value)
 
ByteBufferoperator<< (int8 value)
 
ByteBufferoperator<< (int16 value)
 
ByteBufferoperator<< (int32 value)
 
ByteBufferoperator<< (int64 value)
 
ByteBufferoperator<< (float value)
 
ByteBufferoperator<< (double value)
 
ByteBufferoperator<< (std::string_view value)
 
ByteBufferoperator<< (std::string const &str)
 
ByteBufferoperator<< (char const *str)
 
ByteBufferoperator>> (bool &value)
 
ByteBufferoperator>> (uint8 &value)
 
ByteBufferoperator>> (uint16 &value)
 
ByteBufferoperator>> (uint32 &value)
 
ByteBufferoperator>> (uint64 &value)
 
ByteBufferoperator>> (int8 &value)
 
ByteBufferoperator>> (int16 &value)
 
ByteBufferoperator>> (int32 &value)
 
ByteBufferoperator>> (int64 &value)
 
ByteBufferoperator>> (float &value)
 
ByteBufferoperator>> (double &value)
 
ByteBufferoperator>> (std::string &value)
 
uint8operator[] (std::size_t const pos)
 
uint8 const & operator[] (std::size_t const pos) const
 
std::size_t rpos () const
 
std::size_t rpos (std::size_t rpos_)
 
void rfinish ()
 
std::size_t wpos () const
 
std::size_t wpos (std::size_t wpos_)
 
template<typename T >
void read_skip ()
 
void read_skip (std::size_t skip)
 
template<typename T >
read ()
 
template<typename T >
read (std::size_t pos) const
 
void read (uint8 *dest, std::size_t len)
 
template<std::size_t Size>
void read (std::array< uint8, Size > &arr)
 
void readPackGUID (uint64 &guid)
 
std::string ReadCString (bool requireValidUtf8=true)
 
uint32 ReadPackedTime ()
 
ByteBufferReadPackedTime (uint32 &time)
 
uint8contents ()
 
uint8 const * contents () const
 
std::size_t size () const
 
bool empty () const
 
void resize (std::size_t newsize)
 
void reserve (std::size_t ressize)
 
void shrink_to_fit ()
 
void append (char const *src, std::size_t cnt)
 
template<class T >
void append (const T *src, std::size_t cnt)
 
void append (uint8 const *src, std::size_t cnt)
 
void append (ByteBuffer const &buffer)
 
template<std::size_t Size>
void append (std::array< uint8, Size > const &arr)
 
void appendPackXYZ (float x, float y, float z)
 
void appendPackGUID (uint64 guid)
 
void AppendPackedTime (time_t time)
 
void put (std::size_t pos, uint8 const *src, std::size_t cnt)
 
void print_storage () const
 
void textlike () const
 
void hexlike () const
 
template<>
void read_skip ()
 
template<>
void read_skip ()
 

Public Attributes

std::atomic< EncryptableAndCompressiblePacket * > SocketQueueLink
 

Private Attributes

bool _encrypt
 

Additional Inherited Members

- Static Public Attributes inherited from ByteBuffer
static constexpr std::size_t DEFAULT_SIZE = 0x1000
 
- Protected Attributes inherited from WorldPacket
uint16 m_opcode {NULL_OPCODE}
 
TimePoint m_receivedTime
 
- Protected Attributes inherited from ByteBuffer
std::size_t _rpos {0}
 
std::size_t _wpos {0}
 
std::vector< uint8_storage
 

Detailed Description

Constructor & Destructor Documentation

◆ EncryptableAndCompressiblePacket()

EncryptableAndCompressiblePacket::EncryptableAndCompressiblePacket ( WorldPacket const &  packet,
bool  encrypt 
)
inline
35 : WorldPacket(packet), _encrypt(encrypt)
36 {
37 SocketQueueLink.store(nullptr, std::memory_order_relaxed);
38 }
bool _encrypt
Definition WorldSocket.h:49
std::atomic< EncryptableAndCompressiblePacket * > SocketQueueLink
Definition WorldSocket.h:46
WorldPacket()
Definition WorldPacket.h:29

References SocketQueueLink.

Member Function Documentation

◆ CompressIfNeeded()

void EncryptableAndCompressiblePacket::CompressIfNeeded ( )
98{
99 if (!NeedsCompression())
100 return;
101
102 uint32 pSize = size();
103
104 uint32 destsize = compressBound(pSize);
105 ByteBuffer buf(destsize + sizeof(uint32));
106 buf.resize(destsize + sizeof(uint32));
107
108 buf.put<uint32>(0, pSize);
109 compressBuff(const_cast<uint8*>(buf.contents()) + sizeof(uint32), &destsize, (void*)contents(), pSize);
110 if (destsize == 0)
111 return;
112
113 buf.resize(destsize + sizeof(uint32));
114
115 ByteBuffer::operator=(std::move(buf));
117}
std::uint8_t uint8
Definition Define.h:109
std::uint32_t uint32
Definition Define.h:107
void compressBuff(void *dst, uint32 *dst_size, void *src, int src_size)
Definition WorldSocket.cpp:41
Definition ByteBuffer.h:70
std::size_t size() const
Definition ByteBuffer.h:444
ByteBuffer & operator=(ByteBuffer const &right)
Definition ByteBuffer.h:96
uint8 * contents()
Definition ByteBuffer.h:424
bool NeedsCompression() const
Definition WorldSocket.h:42
void SetOpcode(uint16 opcode)
Definition WorldPacket.h:76
@ SMSG_COMPRESSED_UPDATE_OBJECT
Definition Opcodes.h:532

References compressBuff(), ByteBuffer::contents(), NeedsCompression(), ByteBuffer::operator=(), ByteBuffer::put(), ByteBuffer::resize(), WorldPacket::SetOpcode(), ByteBuffer::size(), and SMSG_COMPRESSED_UPDATE_OBJECT.

Referenced by WorldSocket::Update().

◆ NeedsCompression()

bool EncryptableAndCompressiblePacket::NeedsCompression ( ) const
inline
42{ return GetOpcode() == SMSG_UPDATE_OBJECT && size() > 100; }
uint16 GetOpcode() const
Definition WorldPacket.h:75
@ SMSG_UPDATE_OBJECT
Definition Opcodes.h:199

References WorldPacket::GetOpcode(), ByteBuffer::size(), and SMSG_UPDATE_OBJECT.

Referenced by CompressIfNeeded().

◆ NeedsEncryption()

bool EncryptableAndCompressiblePacket::NeedsEncryption ( ) const
inline
40{ return _encrypt; }

References _encrypt.

Referenced by WorldSocket::Update().

Member Data Documentation

◆ _encrypt

bool EncryptableAndCompressiblePacket::_encrypt
private

Referenced by NeedsEncryption().

◆ SocketQueueLink

std::atomic<EncryptableAndCompressiblePacket*> EncryptableAndCompressiblePacket::SocketQueueLink

The documentation for this class was generated from the following files: