Skip to content

Multiplayer

Some immersive applications are built to allow multiple Participants to interact in a shared world. When multiple sessions have the same LobbyId, it allows our system to logically group these sessions together with minimal client side effort.

Networking Structure

The Cognitive3D SDK is not designed to record multiple sessions from a centralized server. It is designed to run on a client.

Lobby Id

A LobbyId connects multiple participant sessions together to display a multiplayer experience. The Lobby Id value should be generated and set before beginning the session.

Example

A server should generate a unique LobbyId property and replicate it to all the clients. This could be included in the GameState or it could use a multicast RPC to call a function on each client.

```c++
//game server

//generate a unique lobby id
FString lobbyid = FGuid::NewGuid().ToString();

//multicast rpc to each client
MulticastRPCCognitive3DLobbyId(lobbyid);
```

Then, on each Client, record the LobbyId property

lobby id

//game client
TWeakPtr<FAnalyticsProviderCognitive3D> cognitive = FAnalyticsCognitive3D::Get().GetCognitive3DProvider();
if (cognitive.IsValid())
{
    cognitive.Pin()->SetLobbyId(lobbyid);
}