Game Development Community

NetConnection Connection List

by Robert Blanchet Jr. · in Torque Game Engine · 04/30/2003 (2:03 am) · 2 replies

I have what essential amounts to a list of objects that I need to update to clients upon specific events. For this I have relied upon the NetEvent and its various functions to do this. I've come across a problem though I'm hoping someone can shed some light on.

Every so often one of my objects needs to be 'freed' from all the clients at the same time. To do this I need to effectively loop through each connected client on the server and post the appropriate network event handler. The problem is I can't figure out how to loop through the current list of clients.

Here is how I'm doing it, but it never goes through the loop at all, it just skips over it(and yes I'm hosting in a dedicated -> client environment):
for(NetConnection *conn = NetConnection::getConnectionList(); conn; conn = conn->getNext())
{
   if(conn->isServerConnection())
      continue;

   if (dynamic_cast<GameConnection*>(conn) && static_cast<GameConnection*>(conn)->isAIControlled())
      continue;
      
   conn->postNetEvent(new ObjectFreeEvent(object));
}

Like I said, it just skips over the entire loop even though I have a client connected to the server. If anyone can tell me what I'm doing wrong it would greatly be appreciated.

#1
04/30/2003 (9:29 am)
Robert, that's very odd that your code isn't working...

from engine/sim/netInterface.cc
void NetInterface::processServer()
{
   NetObject::collapseDirtyList(); // collapse all the mask bits...
   for(NetConnection *walk = NetConnection::getConnectionList(); walk; walk = walk->getNext())
   {
      if(!walk->isServerConnection() && (walk->isLocalConnection() ||
             walk->isNetworkConnection()))
         walk->checkPacketSend(false);
   }
}
That's the code that sends packets to all the connected clients from the server - so if your code isn't working, this code shouldn't work either. Very strange.
#2
04/30/2003 (11:15 am)
Mark,

It turns out that it is working. During establishing a client connection to the server it apparantly tries to run through that code numerous times, and fails to enter the loop. And then later, just before its about to dump the client into the mission, it then runs through the code and the loop just fine.