AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
ServerPktHeader Struct Reference

#include "ServerPktHeader.h"

Public Member Functions

 ServerPktHeader (uint32 size, uint16 cmd)
 
uint8 getHeaderLength ()
 
bool isLargePacket () const
 

Public Attributes

const uint32 size
 
uint8 header [5]
 

Detailed Description

Constructor & Destructor Documentation

◆ ServerPktHeader()

ServerPktHeader::ServerPktHeader ( uint32  size,
uint16  cmd 
)
inline

size is the length of the payload plus the length of the opcode

30 : size(size)
31 {
32 uint8 headerIndex=0;
33 if (isLargePacket())
34 {
35 LOG_DEBUG("network", "initializing large server to client packet. Size: {}, cmd: {}", size, cmd);
36 header[headerIndex++] = 0x80 | (0xFF & (size >> 16));
37 }
38 header[headerIndex++] = 0xFF &(size >> 8);
39 header[headerIndex++] = 0xFF & size;
40
41 header[headerIndex++] = 0xFF & cmd;
42 header[headerIndex++] = 0xFF & (cmd >> 8);
43 }
#define LOG_DEBUG(filterType__,...)
Definition: Log.h:168
std::uint8_t uint8
Definition: Define.h:109
bool isLargePacket() const
Definition: ServerPktHeader.h:51
const uint32 size
Definition: ServerPktHeader.h:56
uint8 header[5]
Definition: ServerPktHeader.h:57

References header, isLargePacket(), LOG_DEBUG, and size.

Member Function Documentation

◆ getHeaderLength()

uint8 ServerPktHeader::getHeaderLength ( )
inline
46 {
47 // cmd = 2 bytes, size= 2||3bytes
48 return 2 + (isLargePacket() ? 3 : 2);
49 }

References isLargePacket().

Referenced by WorldSocket::Update().

◆ isLargePacket()

bool ServerPktHeader::isLargePacket ( ) const
inline
52 {
53 return size > 0x7FFF;
54 }

References size.

Referenced by getHeaderLength(), and ServerPktHeader().

Member Data Documentation

◆ header

uint8 ServerPktHeader::header[5]

◆ size

const uint32 ServerPktHeader::size

Referenced by isLargePacket(), and ServerPktHeader().