From b426d3e5d269007f95360e40f906c5568a5abc99 Mon Sep 17 00:00:00 2001 From: Aaron Marks Date: Wed, 13 Jul 2005 02:59:19 +0000 Subject: Implemented MessageOut. Rewrote MessageIn::readString - it was overly complex and didn't operate correctly. Update test client so it sends a login message. --- src/connectionhandler.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/connectionhandler.cpp') 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 -- cgit v1.2.3-70-g09d2