Documentation

Support

Multiplayer

Multiplayer

Ways to join a session

Implement ways for joining multiplayer sessions by entering a join code, browsing available sessions, or reconnecting after a disconnection.
Read time 2 minutesLast updated 12 hours ago

A player can join a previously-created session in the following ways:

Join code

await MultiplayerService.Instance.JoinSessionByCodeAsync(joinCode);
A unique and human-friendly join code is generated when a host starts a session. A host can then share this join code with other players to invite them to play the same session. The codes use a combination of letters and numbers and are designed to be short and easy to type or spell out loud. Refer to JoinSessionByCodeAsync.

Browsing sessions in a list

You can use a session query to list sessions.
await MultiplayerService.Instance.QuerySessionsAsync(queryOptions);
Query results include all non-full, public sessions a player can join. Players can select a session from a list displaying only public properties of the session (such as its name), and join directly by session ID.

Reconnect to a session

If a player is disconnected from a session but remains a member of it, they can reconnect to the same session. Implement the following code in your game to handle the cases when a player disconnects. To reconnect a user, do the following:
  1. Fetch all the sessions the current user is part of using GetJoinedSessionIdsAsync:
    await MultiplayerService.Instance.GetJoinedSessionIdsAsync();
  2. To reconnect to the chosen session, call ReconnectAsync:
    await sessionManager.ReconnectAsync(sessionId);
You can add a custom network handler implementation to your reconnect request by specifying a
ReconnectSessionOptions
that uses your own network handler implementation:
await sessionManager.ReconnectAsync(sessionId,new ReconnectSessionOptions().WithNetworkHandler(customNetworkHandler));

Additional resources