summaryrefslogtreecommitdiff
path: root/src/net/connectionhandler.cpp
diff options
context:
space:
mode:
authorGuillaume Melquiond <guillaume.melquiond@gmail.com>2007-01-05 20:12:51 +0000
committerGuillaume Melquiond <guillaume.melquiond@gmail.com>2007-01-05 20:12:51 +0000
commit593e65eef0d43f2ff61dc1b4f3160c0a16b5f015 (patch)
tree8e0a1ca0c73778f0e4d71f4da4d5c47f272915b9 /src/net/connectionhandler.cpp
parentf96ca90ba90da3175be96ff7ed34efb78ea5dfed (diff)
downloadmanaserv-593e65eef0d43f2ff61dc1b4f3160c0a16b5f015.tar.gz
manaserv-593e65eef0d43f2ff61dc1b4f3160c0a16b5f015.tar.bz2
manaserv-593e65eef0d43f2ff61dc1b4f3160c0a16b5f015.tar.xz
manaserv-593e65eef0d43f2ff61dc1b4f3160c0a16b5f015.zip
Simplified handling of verbosity levels. Optimized code by generating only needed messages.
Diffstat (limited to 'src/net/connectionhandler.cpp')
-rw-r--r--src/net/connectionhandler.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/net/connectionhandler.cpp b/src/net/connectionhandler.cpp
index 7782a74a..69ac9337 100644
--- a/src/net/connectionhandler.cpp
+++ b/src/net/connectionhandler.cpp
@@ -49,7 +49,7 @@ bool ConnectionHandler::startListen(enet_uint16 port)
address.host = ENET_HOST_ANY;
address.port = port;
- LOG_INFO("Listening on port " << port << "...", 0);
+ LOG_INFO("Listening on port " << port << "...");
host = enet_host_create(&address /* the address to bind the server host to */,
MAX_CLIENTS /* allow up to MAX_CLIENTS clients and/or outgoing connections */,
0 /* assume any amount of incoming bandwidth */,
@@ -96,7 +96,7 @@ void ConnectionHandler::process()
LOG_INFO("A new client connected from " <<
ip4ToString(event.peer->address.host) << ":" <<
event.peer->address.port << " to port " <<
- host->address.port, 0);
+ host->address.port);
NetComputer *comp = computerConnected(event.peer);
clients.push_back(comp);
@@ -124,13 +124,13 @@ void ConnectionHandler::process()
if (event.packet->dataLength >= 2) {
MessageIn msg((char *)event.packet->data,
event.packet->dataLength);
- LOG_INFO("Received message " << msg.getId() << " ("
- << event.packet->dataLength << " B) from "
- << *comp, 2);
+ LOG_DEBUG("Received message " << msg.getId() << " ("
+ << event.packet->dataLength << " B) from "
+ << *comp);
processMessage(comp, msg);
} else {
- LOG_ERROR("Message too short from " << *comp, 0);
+ LOG_ERROR("Message too short from " << *comp);
}
/* Clean up the packet now that we're done using it. */
@@ -140,7 +140,7 @@ void ConnectionHandler::process()
case ENET_EVENT_TYPE_DISCONNECT:
{
NetComputer *comp = (NetComputer *)event.peer->data;
- LOG_INFO(ip4ToString(event.peer->address.host) << " disconnected.", 0);
+ LOG_INFO(ip4ToString(event.peer->address.host) << " disconnected.");
// Reset the peer's client information.
computerDisconnected(comp);
clients.erase(std::find(clients.begin(), clients.end(), comp));
@@ -155,7 +155,8 @@ void ConnectionHandler::process()
void ConnectionHandler::sendToEveryone(const MessageOut &msg)
{
for (NetComputers::iterator i = clients.begin(), i_end = clients.end();
- i != i_end; ++i) {
+ i != i_end; ++i)
+ {
(*i)->send(msg);
}
}