You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.
Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.
// find a host or become one.
_networkId = agk::JoinNetwork("tanks", "client");
float t = agk::Timer();
bool connected = false;
agk::PrintC("Searching for host...");
connected = (agk::GetNetworkNumClients(_networkId) > 0);
// found a host, so we're a client.
_netState = iAmClient;
_theServerId = agk::GetNetworkServerID(_networkId);
// no host found, but give it two seconds...
if ((agk::Timer() - t > 2) && !connected)
agk::Print("not found, so hosting.");
// ...and then become the host.
_networkId = agk::HostNetwork("tanks", "host", 1041);
_netState = iAmHost;
connected = true;
} while (!connected);
// now we're connected, get our client ID.
_myClientId = agk::GetNetworkMyClientID(_networkId);
Login to post a reply