TGB/Networking/Handling Client Connections
From TDN
TGB Networking >> Handling Client Connections
Handling Client Connections
After you have created a server, client connections are automatically accepted. When a new client connects, the onClientConnected(%client) callback is called. If the client is dropped for any reason, the onClientDropped(%client) callback is called.
The server can access a list of the clients connected to it through the named group ClientGroup. Each object inside of ClientGroup is an instance of the GameConnection class. (For the curious, the content of ClientGroup is maintained directly by the C++ code.) Typically, all you'll need to do with ClientGroup itself is find out the number of clients, and get a reference to a particular client. Here's a simple example that echoes the name of each client:
%numberOfClients = ClientGroup.getCount();
for (%i = 0; %i < % numberOfClients; %i++)
{
%client = ClientGroup.getObject(%i);
echo(%client.name);
}
Categories: Networking | Server | Client | TGB



