Use logger in server's Networking MainLoop

pull/78/head
David Cernat 8 years ago
parent fcc793a0af
commit 5e0c0dd5f1

@ -47,7 +47,6 @@ Networking::~Networking()
void Networking::Update(RakNet::Packet *packet)
{
Player *player = Players::GetPlayer(packet->guid);
RakNet::BitStream bsIn(&packet->data[1], packet->length, false);
@ -73,7 +72,6 @@ void Networking::Update(RakNet::Packet *packet)
if (packet->data[0] == ID_HANDSHAKE)
{
DEBUG_PRINTF("ID_HANDSHAKE\n");
string passw = "SuperPassword";
myPacket->Read(player);
@ -448,31 +446,37 @@ int Networking::MainLoop()
switch (packet->data[0])
{
case ID_REMOTE_DISCONNECTION_NOTIFICATION:
printf("Another client has disconnected.\n");
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Client at %s has disconnected",
packet->systemAddress.ToString());
break;
case ID_REMOTE_CONNECTION_LOST:
printf("Another client has lost connection.\n");
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Client at %s has lost connection",
packet->systemAddress.ToString());
break;
case ID_REMOTE_NEW_INCOMING_CONNECTION:
printf("Another client has connected.\n");
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Client at %s has connected",
packet->systemAddress.ToString());
break;
case ID_CONNECTION_REQUEST_ACCEPTED: // client to server
{
printf("Our connection request has been accepted.\n");
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "%s", "Our connection request has been accepted");
break;
}
case ID_NEW_INCOMING_CONNECTION:
printf("A connection is incoming.\n");
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "A connection is incoming from %s",
packet->systemAddress.ToString());
break;
case ID_NO_FREE_INCOMING_CONNECTIONS:
printf("The server is full.\n");
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "%s", "The server is full");
break;
case ID_DISCONNECTION_NOTIFICATION:
printf("A client has disconnected.\n");
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Client at %s has disconnected",
packet->systemAddress.ToString());
DisconnectPlayer(packet->guid);
break;
case ID_CONNECTION_LOST:
printf("A client has lost connection.\n");
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Client at %s has lost connection",
packet->systemAddress.ToString());
DisconnectPlayer(packet->guid);
break;
default:

@ -49,10 +49,10 @@ void PlayerPacket::Read(BasePlayer *player)
Packet(bsRead, player, false);
}
void PlayerPacket::RequestData(RakNet::RakNetGUID player)
void PlayerPacket::RequestData(RakNet::RakNetGUID guid)
{
bsSend->ResetWritePointer();
bsSend->Write(packetID);
bsSend->Write(player);
peer->Send(bsSend, HIGH_PRIORITY, RELIABLE_ORDERED, 0, player, false);
peer->Send(bsSend, HIGH_PRIORITY, RELIABLE_ORDERED, 0, guid, false);
}

Loading…
Cancel
Save