mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-12 09:31:30 +00:00
* Convert common/eq_limits.cpp to use make_unique * Convert common/net/console_server.cpp to use make_unique * Convert common/net/servertalk_client_connection.cpp to use make_unique * Convert common/net/servertalk_legacy_client_connection.cpp to use make_unique * Convert common/net/servertalk_server.cpp to use make_unique * Convert common/net/websocket_server.cpp to use make_unique * Convert common/net/websocket_server_connection.cpp to use make_unique * Convert common/shareddb.cpp to use make_unique * Convert eqlaunch/worldserver.cpp to use make_unique * Convert loginserver/server_manager.cpp to use make_unique * Convert loginserver/world_server.cpp to use make_unique * Convert queryserv/worldserver.cpp to use make_unique * Convert ucs/worldserver.cpp to use make_unique * Convert world/clientlist.cpp to use make_unique * Convert world/expedition.cpp to use make_unique * Convert world/launcher_link.cpp to use make_unique * Convert world/login_server.cpp to use make_unique * Convert world/main.cpp to use make_unique * Convert world/ucs.cpp to use make_unique * Convert world/web_interface.cpp to use make_unique * Convert world/zonelist.cpp to use make_unique * Convert world/zoneserver.cpp to use make_unique * Convert zone/client.cpp to use make_unique * Convert zone/corpse.cpp to use make_unique * Convert zone/dynamiczone.cpp to use make_unique * Convert zone/expedition.cpp to use make_unique * Convert zone/main.cpp to use make_unique * Convert zone/mob_ai.cpp to use make_unique * Convert zone/mob_movement_manager.cpp to use make_unique * Convert zone/pathfinder_nav_mesh.cpp to use make_unique * Convert zone/worldserver.cpp to use make_unique
105 lines
2.1 KiB
C++
105 lines
2.1 KiB
C++
#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
|
|
)
|
|
);
|
|
}
|
|
|
|
m_keepalive = std::make_unique<EQ::Timer>(1000, true, std::bind(&UCSConnection::OnKeepAlive, this, std::placeholders::_1));
|
|
}
|
|
|
|
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);
|
|
}
|
|
|
|
void UCSConnection::OnKeepAlive(EQ::Timer *t)
|
|
{
|
|
if (!connection) {
|
|
return;
|
|
}
|
|
|
|
ServerPacket pack(ServerOP_KeepAlive, 0);
|
|
connection->SendPacket(&pack);
|
|
}
|