Repository navigation
Expand file tree
/
Copy pathucs.cpp
More file actions
92 lines (77 loc) · 1.85 KB
/
Copy pathucs.cpp
File metadata and controls
92 lines (77 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#include "../common/global_define.h"
#include "../common/eqemu_logsys.h"
#include "ucs.h"
#include "world_config.h"
#include "../common/misc_functions.h"
#include "../common/md5.h"
#include "../common/packet_dump.h"
#include "../common/event/timer.h"
UCSConnection::UCSConnection()
{
connection = 0;
}
void UCSConnection::SetConnection(std::shared_ptr<EQ::Net::ServertalkServerConnection> inStream)
{
if (inStream && connection && connection->Handle()) {
LogInfo("Incoming UCS Connection while we were already connected to a UCS");
connection->Handle()->Disconnect();
}
connection = inStream;
if (connection) {
connection->OnMessage(
std::bind(
&UCSConnection::ProcessPacket,
this,
std::placeholders::_1,
std::placeholders::_2
)
);
}
}
const std::shared_ptr<EQ::Net::ServertalkServerConnection> &UCSConnection::GetConnection() const
{
return connection;
}
void UCSConnection::ProcessPacket(uint16 opcode, EQ::Net::Packet &p)
{
if (!connection)
return;
ServerPacket tpack(opcode, p);
ServerPacket *pack = &tpack;
switch (opcode)
{
case 0:
break;
case ServerOP_KeepAlive:
{
// ignore this
break;
}
case ServerOP_ZAAuth:
{
LogInfo("Got authentication from UCS when they are already authenticated");
break;
}
default:
{
LogInfo("Unknown ServerOPcode from UCS {:#04x}, size [{}]", opcode, pack->size);
DumpPacket(pack->pBuffer, pack->size);
break;
}
}
}
void UCSConnection::SendPacket(ServerPacket* pack)
{
if (!connection)
return;
connection->SendPacket(pack);
}
void UCSConnection::SendMessage(const char *From, const char *Message)
{
auto pack = new ServerPacket(ServerOP_UCSMessage, strlen(From) + strlen(Message) + 2);
char *Buffer = (char *)pack->pBuffer;
VARSTRUCT_ENCODE_STRING(Buffer, From);
VARSTRUCT_ENCODE_STRING(Buffer, Message);
SendPacket(pack);
safe_delete(pack);
}