Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Toggle main menu visibility
Loading...
Searching...
No Matches
PacketLog.cpp
Go to the documentation of this file.
1
/*
2
* This file is part of Project SkyFire https://www.projectskyfire.org.
3
* See LICENSE.md file for Copyright information
4
*/
5
6
#include "
Opcodes.h
"
7
#include "
PacketLog.h
"
8
#include "
WorldPacket.h
"
9
10
namespace
11
{
12
Skyfire::PacketLogServerDirection
ToPacketLogServerDirection(
Direction
direction)
13
{
14
return
direction ==
CLIENT_TO_SERVER
?
Skyfire::PACKET_LOG_CLIENT_TO_SERVER
:
Skyfire::PACKET_LOG_SERVER_TO_CLIENT
;
15
}
16
}
17
18
PacketLog::PacketLog
()
19
{
20
Initialize
();
21
}
22
23
PacketLog::~PacketLog
()
24
{
25
}
26
27
void
PacketLog::Initialize
()
28
{
29
sPacketLogServer
->Initialize(
"packetlogserver.active"
,
"PacketLogs"
);
30
}
31
32
bool
PacketLog::CanLogPacket
()
const
33
{
34
return
sPacketLogServer
->CanLogPacket();
35
}
36
37
void
PacketLog::LogPacket
(
WorldPacket
const
& packet,
Direction
direction)
38
{
39
uint32
opcode = direction ==
CLIENT_TO_SERVER
?
const_cast<
WorldPacket
&
>
(packet).GetReceivedOpcode() :
serverOpcodeTable
[packet.
GetOpcode
()]->OpcodeNumber;
40
sPacketLogServer
->LogBinaryPacket(ToPacketLogServerDirection(direction), opcode,
41
packet.
size
() ? packet.
contents
() : NULL, packet.
size
());
42
}
43
44
void
PacketLog::EnableGlobalLogging
()
45
{
46
sPacketLogServer
->EnableGlobalLogging();
47
}
48
49
void
PacketLog::DisableAllLogging
()
50
{
51
sPacketLogServer
->DisableAllLogging();
52
}
53
54
void
PacketLog::EnableCharacterLogging
(std::string
const
& characterName)
55
{
56
sPacketLogServer
->EnableCharacterLogging(characterName);
57
}
58
59
void
PacketLog::DisableCharacterLogging
(std::string
const
& characterName)
60
{
61
sPacketLogServer
->DisableCharacterLogging(characterName);
62
}
63
64
bool
PacketLog::IsGlobalLoggingEnabled
()
const
65
{
66
return
sPacketLogServer
->IsGlobalLoggingEnabled();
67
}
68
69
size_t
PacketLog::GetCharacterLoggingCount
()
const
70
{
71
return
sPacketLogServer
->GetCharacterLoggingCount();
72
}
73
74
void
PacketLog::LogPacket
(
void
const
* sessionKey,
PacketLogSessionInfo
const
& sessionInfo,
WorldPacket
const
& packet,
Direction
direction)
75
{
76
LogPacket
(packet, direction);
77
78
uint32
opcode = direction ==
CLIENT_TO_SERVER
?
const_cast<
WorldPacket
&
>
(packet).GetReceivedOpcode() :
serverOpcodeTable
[packet.
GetOpcode
()]->OpcodeNumber;
79
std::string opcodeName =
GetOpcodeNameForLogging
(packet.
GetOpcode
(), direction ==
SERVER_TO_CLIENT
);
80
sPacketLogServer
->LogPacket(sessionKey, sessionInfo, ToPacketLogServerDirection(direction), opcode, opcodeName,
81
packet.
size
() ? packet.
contents
() : NULL, packet.
size
());
82
}
83
84
void
PacketLog::LogMarker
(
void
const
* sessionKey,
PacketLogSessionInfo
const
& sessionInfo, std::string
const
& marker)
85
{
86
sPacketLogServer
->LogMarker(sessionKey, sessionInfo, marker);
87
}
88
89
void
PacketLog::RefreshSessionInfo
(
void
const
* sessionKey,
PacketLogSessionInfo
const
& sessionInfo)
90
{
91
sPacketLogServer
->RefreshSessionInfo(sessionKey, sessionInfo);
92
}
93
94
void
PacketLog::CloseSession
(
void
const
* sessionKey)
95
{
96
sPacketLogServer
->CloseSession(sessionKey);
97
}
uint32
std::uint32_t uint32
Definition
Define.h:77
Opcodes.h
PacketLog.h
PacketLogSessionInfo
Skyfire::PacketLogServerSessionInfo PacketLogSessionInfo
Definition
PacketLog.h:21
Direction
Direction
Definition
PacketLog.h:14
SERVER_TO_CLIENT
@ SERVER_TO_CLIENT
Definition
PacketLog.h:16
CLIENT_TO_SERVER
@ CLIENT_TO_SERVER
Definition
PacketLog.h:15
sPacketLogServer
#define sPacketLogServer
Definition
PacketLogServer.h:95
WorldPacket.h
ByteBuffer::size
size_t size() const
Definition
ByteBuffer.h:609
ByteBuffer::contents
uint8 * contents()
Definition
ByteBuffer.h:605
PacketLog::LogPacket
void LogPacket(WorldPacket const &packet, Direction direction)
Definition
PacketLog.cpp:37
PacketLog::DisableCharacterLogging
void DisableCharacterLogging(std::string const &characterName)
Definition
PacketLog.cpp:59
PacketLog::RefreshSessionInfo
void RefreshSessionInfo(void const *sessionKey, PacketLogSessionInfo const &sessionInfo)
Definition
PacketLog.cpp:89
PacketLog::CanLogPacket
bool CanLogPacket() const
Definition
PacketLog.cpp:32
PacketLog::CloseSession
void CloseSession(void const *sessionKey)
Definition
PacketLog.cpp:94
PacketLog::GetCharacterLoggingCount
size_t GetCharacterLoggingCount() const
Definition
PacketLog.cpp:69
PacketLog::~PacketLog
~PacketLog()
Definition
PacketLog.cpp:23
PacketLog::EnableGlobalLogging
void EnableGlobalLogging()
Definition
PacketLog.cpp:44
PacketLog::EnableCharacterLogging
void EnableCharacterLogging(std::string const &characterName)
Definition
PacketLog.cpp:54
PacketLog::PacketLog
PacketLog()
Definition
PacketLog.cpp:18
PacketLog::IsGlobalLoggingEnabled
bool IsGlobalLoggingEnabled() const
Definition
PacketLog.cpp:64
PacketLog::LogMarker
void LogMarker(void const *sessionKey, PacketLogSessionInfo const &sessionInfo, std::string const &marker)
Definition
PacketLog.cpp:84
PacketLog::DisableAllLogging
void DisableAllLogging()
Definition
PacketLog.cpp:49
PacketLog::Initialize
void Initialize()
Definition
PacketLog.cpp:27
WorldPacket
Definition
WorldPacket.h:16
WorldPacket::GetOpcode
Opcodes GetOpcode() const
Definition
WorldPacket.h:38
GetOpcodeNameForLogging
std::string GetOpcodeNameForLogging(Opcodes id, bool isServerOpcode, uint16 opcodeNumber=0)
Lookup opcode name for human understandable logging.
Definition
Opcodes.h:1157
serverOpcodeTable
OpcodeTable serverOpcodeTable
Definition
Opcodes.cpp:9
Skyfire::PacketLogServerDirection
PacketLogServerDirection
Definition
PacketLogServer.h:22
Skyfire::PACKET_LOG_SERVER_TO_CLIENT
@ PACKET_LOG_SERVER_TO_CLIENT
Definition
PacketLogServer.h:24
Skyfire::PACKET_LOG_CLIENT_TO_SERVER
@ PACKET_LOG_CLIENT_TO_SERVER
Definition
PacketLogServer.h:23
src
server
game
Server
Protocol
PacketLog.cpp
Generated on
for Project SkyFire Core by
1.17.0