From 62395df8a674475cd7b277e964cc5512fa6e7576 Mon Sep 17 00:00:00 2001 From: Aaron Marks Date: Mon, 18 Jul 2005 11:47:00 +0000 Subject: Updated server->client communications. --- src/connectionhandler.cpp | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) (limited to 'src/connectionhandler.cpp') diff --git a/src/connectionhandler.cpp b/src/connectionhandler.cpp index d0a0d23..338913f 100644 --- a/src/connectionhandler.cpp +++ b/src/connectionhandler.cpp @@ -135,8 +135,8 @@ ConnectionHandler::startListen(ListenThreadData *ltd) LOG_ERROR("SDLNet_AddSocket: " << SDLNet_GetError()) } else { - NetComputer *comp = new NetComputer(this); - clients[comp] = client; + NetComputer *comp = new NetComputer(this, client); + clients.push_back(comp); computerConnected(comp); LOG_INFO(clients.size() << " clients connected") } @@ -144,10 +144,10 @@ ConnectionHandler::startListen(ListenThreadData *ltd) } // Check client sockets - std::map::iterator i; + std::list::iterator i; for (i = clients.begin(); i != clients.end(); ) { - NetComputer *comp = (*i).first; - TCPsocket s = (*i).second; + NetComputer *comp = *i; + TCPsocket s = (*i)->getSocket(); if (SDLNet_SocketReady(s)) { char buffer[1024]; @@ -213,7 +213,7 @@ ConnectionHandler::startListen(ListenThreadData *ltd) // Traverse to next client, possibly deleting current if (comp == NULL) { - std::map::iterator ii = i; + std::list::iterator ii = i; ii++; clients.erase(i); i = ii; @@ -245,18 +245,3 @@ void ConnectionHandler::registerHandler( { handlers[msgId] = handler; } - -void ConnectionHandler::sendPackets() -{ - for (std::map::iterator i = clients.begin(); - i != clients.end(); i++) { - NetComputer *computer = i->first; - - while (computer->size() > 0) { - // Send queued packet - Packet *packet = computer->front(); - SDLNet_TCP_Send(i->second, packet->data, packet->length); - delete packet; - } - } -} -- cgit