Skip to content

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.

We support this feature in both Unity and Unreal

An example implementation for Unity is as follows:

Request unique LobbyId from Cognitive3D API:

Note

Unlike the rest of the REST API, the lobbies endpoint authenticates with your application API key (sent as APIKEY:DATA), not your organization API key. Find it in the Project Keys dialog, opened from Manage Developer Key in the dashboard's gear/settings menu.

// 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 the application API key to the 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);

intercom If you have a question or any feedback about our documentation please use the Intercom button (purple circle) in the lower right corner of any web page or join our Discord.