TGB/Networking/Creating a Server
From TDN
TGB Networking >> Creating a Server
Creating a Server
While the standard StartServerGui dialog takes care of creating a server for you, it's extremely easy to create one manually. All it requires is a single line of code:
createServer(%displayOnMasterServer);
Calling the createServer() function will automatically tell the master server that the server is available (and will be shown in the server list for other players if the %displayOnMasterServer parameter is true), enable the game to accept incoming connections from other players, and create a loopback connection from the local client to the server.
The createServer() function will call the onServerCreated() callback function, as well as set these global variables:
$serverLocal = true; $serverCreated = true;
$serverLocal and $serverCreated are logically identical, describing whether or not the game is running a server or not.
Because createServer() also creates a local connection from the client to the server within the same game instance, the client-related callbacks (onConnected() etc) will also be called as appropriate.
Categories: Networking | Server | TGB



