summaryrefslogtreecommitdiff
path: root/src/account-server
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2012-04-14 12:59:54 +0200
committerThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2012-05-05 22:51:32 +0200
commitbb9a9b9b0f4ec7cc6a9ca3a6bd2dc35b0b6541e7 (patch)
tree503dcb475ece8e72e2fbef2e78e82b2a881e6d23 /src/account-server
parent05669aae551820f2183984d1c706d3a82eb37be6 (diff)
downloadmanaserv-bb9a9b9b0f4ec7cc6a9ca3a6bd2dc35b0b6541e7.tar.gz
manaserv-bb9a9b9b0f4ec7cc6a9ca3a6bd2dc35b0b6541e7.tar.bz2
manaserv-bb9a9b9b0f4ec7cc6a9ca3a6bd2dc35b0b6541e7.tar.xz
manaserv-bb9a9b9b0f4ec7cc6a9ca3a6bd2dc35b0b6541e7.zip
Added debugging mode to the protocol
Allows inspection of message data. It is off by default since it consumes additional bandwidth, but it can be turned on using the net_debugMode option in manaserv.xml. Currently the option only affects outgoing data for each host individually. In particular, enabling this debug mode for the server does not automatically make the client annotate its messages. Reviewed-by: Erik Schilling
Diffstat (limited to 'src/account-server')
-rw-r--r--src/account-server/main-account.cpp3
-rw-r--r--src/account-server/serverhandler.cpp20
2 files changed, 13 insertions, 10 deletions
diff --git a/src/account-server/main-account.cpp b/src/account-server/main-account.cpp
index 44e65c41..65c5efd1 100644
--- a/src/account-server/main-account.cpp
+++ b/src/account-server/main-account.cpp
@@ -345,6 +345,9 @@ int main(int argc, char *argv[])
int chatClientPort = Configuration::getValue("net_chatListenToClientPort",
options.port + 2);
+ bool debugNetwork = Configuration::getBoolValue("net_debugMode", false);
+ MessageOut::setDebugModeEnabled(debugNetwork);
+
if (!AccountClientHandler::initialize(DEFAULT_ATTRIBUTEDB_FILE,
options.port, accountHost) ||
!GameServerHandler::initialize(accountGamePort, accountHost) ||
diff --git a/src/account-server/serverhandler.cpp b/src/account-server/serverhandler.cpp
index a7d87da9..c938324f 100644
--- a/src/account-server/serverhandler.cpp
+++ b/src/account-server/serverhandler.cpp
@@ -172,7 +172,6 @@ void GameServerHandler::registerClient(const std::string &token,
void ServerHandler::processMessage(NetComputer *comp, MessageIn &msg)
{
- MessageOut result;
GameServer *server = static_cast<GameServer *>(comp);
switch (msg.getId())
@@ -322,11 +321,12 @@ void ServerHandler::processMessage(NetComputer *comp, MessageIn &msg)
if (GameServer *s = getGameServerFromMap(mapId))
{
registerGameClient(s, magic_token, ptr);
- result.writeInt16(AGMSG_REDIRECT_RESPONSE);
+ MessageOut result(AGMSG_REDIRECT_RESPONSE);
result.writeInt32(id);
result.writeString(magic_token, MAGIC_TOKEN_LENGTH);
result.writeString(s->address);
result.writeInt16(s->port);
+ comp->send(result);
}
else
{
@@ -366,10 +366,11 @@ void ServerHandler::processMessage(NetComputer *comp, MessageIn &msg)
int id = msg.readInt32();
std::string name = msg.readString();
std::string value = storage->getQuestVar(id, name);
- result.writeInt16(AGMSG_GET_VAR_CHR_RESPONSE);
+ MessageOut result(AGMSG_GET_VAR_CHR_RESPONSE);
result.writeInt32(id);
result.writeString(name);
result.writeString(value);
+ comp->send(result);
} break;
case GAMSG_SET_VAR_CHR:
@@ -463,7 +464,7 @@ void ServerHandler::processMessage(NetComputer *comp, MessageIn &msg)
{
// Retrieve the post for user
LOG_DEBUG("GCMSG_REQUEST_POST");
- result.writeInt16(CGMSG_POST_RESPONSE);
+ MessageOut result(CGMSG_POST_RESPONSE);
// get the character id
int characterId = msg.readInt32();
@@ -505,13 +506,14 @@ void ServerHandler::processMessage(NetComputer *comp, MessageIn &msg)
postalManager->clearPost(ptr);
}
+ comp->send(result);
} break;
case GCMSG_STORE_POST:
{
// Store the letter for the user
LOG_DEBUG("GCMSG_STORE_POST");
- result.writeInt16(CGMSG_STORE_POST_RESPONSE);
+ MessageOut result(CGMSG_STORE_POST_RESPONSE);
// get the sender and receiver
int senderId = msg.readInt32();
@@ -554,6 +556,7 @@ void ServerHandler::processMessage(NetComputer *comp, MessageIn &msg)
postalManager->addLetter(letter);
result.writeInt8(ERRMSG_OK);
+ comp->send(result);
} break;
case GAMSG_TRANSACTION:
@@ -613,13 +616,10 @@ void ServerHandler::processMessage(NetComputer *comp, MessageIn &msg)
default:
LOG_WARN("ServerHandler::processMessage, Invalid message type: "
<< msg.getId());
- result.writeInt16(XXMSG_INVALID);
+ MessageOut result(XXMSG_INVALID);
+ comp->send(result);
break;
}
-
- // return result
- if (result.getLength() > 0)
- comp->send(result);
}
void GameServerHandler::dumpStatistics(std::ostream &os)