diff options
author | Aaron Marks <nymacro@gmail.com> | 2005-07-13 02:59:19 +0000 |
---|---|---|
committer | Aaron Marks <nymacro@gmail.com> | 2005-07-13 02:59:19 +0000 |
commit | b426d3e5d269007f95360e40f906c5568a5abc99 (patch) | |
tree | 0dd6a4ad8ed1db374b74b6ea01d0eacb7dd50abb /src/connectionhandler.cpp | |
parent | 960f631a2be601357424f9e6c5cdc64b68bff856 (diff) | |
download | manaserv-b426d3e5d269007f95360e40f906c5568a5abc99.tar.gz manaserv-b426d3e5d269007f95360e40f906c5568a5abc99.tar.bz2 manaserv-b426d3e5d269007f95360e40f906c5568a5abc99.tar.xz manaserv-b426d3e5d269007f95360e40f906c5568a5abc99.zip |
Implemented MessageOut.
Rewrote MessageIn::readString - it was overly complex and didn't operate
correctly.
Update test client so it sends a login message.
Diffstat (limited to 'src/connectionhandler.cpp')
-rw-r--r-- | src/connectionhandler.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/connectionhandler.cpp b/src/connectionhandler.cpp index 98d4a748..2b3b64d0 100644 --- a/src/connectionhandler.cpp +++ b/src/connectionhandler.cpp @@ -156,8 +156,13 @@ void ConnectionHandler::startListen(ListenThreadData *ltd) else { // Copy the incoming data to the in buffer of this // client - buffer[result] = 0; - LOG_INFO("Received " << buffer); + //buffer[result] = 0; + //LOG_INFO("Received: " << buffer << ", Length: " + // << result); + + + LOG_INFO("Received length: " + << result); #ifdef SCRIPT_SUPPORT // this could be good if you wanted to extend the @@ -175,11 +180,11 @@ void ConnectionHandler::startListen(ListenThreadData *ltd) std::string ipaddr = ip4ToString(SDLNet_TCP_GetPeerAddress(s)->host); // generate packet - Packet *packet = new Packet(buffer, strlen(buffer)); + Packet *packet = new Packet(buffer, result); MessageIn msg(packet); // (MessageIn frees packet) // make sure that the packet is big enough - if (strlen(buffer) >= 4) { + if (result >= 4) { unsigned int messageType = (unsigned int)*packet->data; if (handlers.find(messageType) != handlers.end()) { // send message to appropriate handler |