1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-23 22:37:55 +02:00

Added basic logging

This commit is contained in:
Ivan Savenko
2024-02-02 00:21:52 +02:00
parent c9ebf32efd
commit ad547fcae0
2 changed files with 20 additions and 3 deletions

View File

@@ -252,6 +252,9 @@ void LobbyServer::onPacketReceived(const NetworkConnectionPtr & connection, cons
// communication messages from vcmiclient
if(activeAccounts.count(connection))
{
std::string accountName = activeAccounts.at(connection).accountID;
logGlobal->info("%s: Received message of type %s", accountName, messageType);
if(messageType == "sendChatMessage")
return receiveSendChatMessage(connection, json);
@@ -267,20 +270,25 @@ void LobbyServer::onPacketReceived(const NetworkConnectionPtr & connection, cons
if(messageType == "declineInvite")
return receiveDeclineInvite(connection, json);
logGlobal->info("Received unexpected message of type %s from account %s", messageType, activeAccounts.at(connection).accountID);
logGlobal->warn("%s: Unknown message type: %s", accountName, messageType);
return;
}
// communication messages from vcmiserver
if(activeGameRooms.count(connection))
{
std::string roomName = activeGameRooms.at(connection).roomID;
logGlobal->info("%s: Received message of type %s", roomName, messageType);
if(messageType == "leaveGameRoom")
return receiveLeaveGameRoom(connection, json);
logGlobal->info("Received unexpected message of type %s from game room %s", messageType, activeGameRooms.at(connection).roomID);
logGlobal->warn("%s: Unknown message type: %s", roomName, messageType);
return;
}
logGlobal->info("(unauthorised): Received message of type %s", messageType);
// unauthorized connections - permit only login or register attempts
if(messageType == "clientLogin")
return receiveClientLogin(connection, json);
@@ -300,7 +308,7 @@ void LobbyServer::onPacketReceived(const NetworkConnectionPtr & connection, cons
// TODO: add logging of suspicious connections.
networkServer->closeConnection(connection);
logGlobal->info("Received unexpected message of type %s from not authorised account!", messageType);
logGlobal->info("(unauthorised): Unknown message type %s", messageType);
}
void LobbyServer::receiveSendChatMessage(const NetworkConnectionPtr & connection, const JsonNode & json)