Lobbies
Adding multiple users in a session works by invoking the lobbies
API.
A LobbyId connects multiple user sessions together to display a multiplayer experience.
When multiple sessions have the same LobbyId, it allows our system to logically group these sessions together with minimal client side effort.
An example implementation is as follows:
Request unique LobbyId from Cognitive3D API:
// Unity game server example code: class LobbyResponse { public string id; } IEnumerator GetLobbyId(string APIKey) { // Post to Lobbies API using (UnityWebRequest www = UnityWebRequest.Post("https://data.cognitive3d.com/v0/lobbies","")) { // Add Project APIKey to header www.SetRequestHeader("Authorization", "APIKEY:DATA " + APIKey); yield return www.SendWebRequest(); // Get response LobbyResponse lobbyresponse = JsonUtility.FromJson<LobbyResponse>(www.downloadHandler.text); } }
Set LobbyId for each client:
// Game client CognitiveVR_Manager.SetLobbyId(lobbyid);