Skip to content

Instantly share code, notes, and snippets.

@ChristianHohlfeld
Created October 4, 2018 20:14
Show Gist options
  • Save ChristianHohlfeld/37a3071d30cced4af8ddd9613813dad1 to your computer and use it in GitHub Desktop.
Save ChristianHohlfeld/37a3071d30cced4af8ddd9613813dad1 to your computer and use it in GitHub Desktop.
Client init
double cTime = 100.0f;
uint64_t clientId = 0;
const double deltaTime = 0.01f;
void HelloWorld::initClient() {
GameAdapter gameAdapter = GameAdapter(&GetDefaultAllocator());
random_bytes((uint8_t*)&clientId, 8);
log("client id is %.16" PRIx64 "\n", clientId);
yojimbo::Address* clientAddress = new Address(localProperties.GetProperty("CLIENT_IP_ADDRESS").c_str()); //TODO: delete
GameConnectionConfig config;
client = new GameClient(GetDefaultAllocator(), clientAddress, gameAdapter, config, cTime); // TODO: delete
Address serverAddress(localProperties.GetProperty("SERVER_IP_ADDRESS").c_str(), 4000);
client->SetServerAddress(&serverAddress);
client->InsecureConnect(privateKey, clientId);
char addressString[256];
client->GetAddress().ToString(addressString, sizeof(addressString));
log("client address is %s\n", addressString);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment