Skip to main content
Multiplayer

Not translated yet — showing English.

Connecting to a Game

A player gets into a match in three moves: sign in, get a reservation for a seat, and connect to the room's server with it. PlayServ finds the room and hands out the ticket; your game server checks the ticket and lets the player in. The game never talks to the machines or the hosting provider: it only gets an address and a ticket.


Before you start

You needWhere
A game connected to PlayServ, with a client keyConnect Your Game
A game server that registers roomsGame Server Hosting
Room settings for that game serverServers → Room settings. Without them, every room call fails with RoomTypeNotFound.

The flow

Sign in

PlayServ.Connect() signs in an anonymous player, or the player signs in with a provider. Every room call is made as that player. See User Login.

Get a reservation

Join a room your servers run, or ask for a new one. Either way the answer is a reservation: the room's name, where to connect, and a one-time ticket.

using Playserv.Matchmaking;
using Playserv.Wrapper;

PlayServMatchReservation reservation;
try
{
    var page = await PlayServMatchmaking.BrowseRoomsAsync("sky-arena",
        new PlayServRoomBrowseQuery { PlacementState = "open" });

    var result = page.Rooms.Count > 0
        ? await PlayServMatchmaking.JoinRoomAsync("sky-arena", page.Rooms[0].RoomName)
        : await PlayServMatchmaking.HostRoomAsync(new PlayServHostRoomRequest { FunctionSlug = "sky-arena" });
    reservation = result.Reservation;
}
catch (PlayServMatchmakingException e)
{
    ShowError(e.RoomFailureCode);
    return;
}

All the options and refusals are in Browse, Host & Join Rooms.

Connect before the ticket expires

Connect to reservation.Connect and give the server reservation.ReservationToken. The ticket is valid for the room type's Reservation TTL, 20 seconds by default, so connect right away.

Play

Game traffic goes over your connection to the server. The server can also send events to everyone in the room through a group.


Connect to the server

How the game connects depends on the server:

ServerHow the game connects
Your own netcode, such as a Unity Dedicated Server with Netcode for GameObjects or MirrorPoint your transport at Connect.Host and Connect.Port (or Connect.ConnectString), and send ReservationToken in your connection request. The server checks it with PlayServ, see Admit players.
PlayServ's game connection, used by C# game serversPlayServMatchmaking.CreateRoomSession(...) connects, sends the ticket and rejoins after a drop; CreateGameConnection() does the same once. See Room sessions.

JoinRoomAndConnectAsync joins, waits until the room's address is known, and runs your connect code in one call, see Join and connect in one call.

Connect can be empty

reservation.Connect is null while the server hasn't reported its address. Wait and join again, or use JoinRoomAndConnectAsync, which waits for it.


Reconnect after a drop

Join the same room again

Call JoinRoomAsync with the room's name for a new ticket. A used ticket never works twice.

Connect with the new ticket

A player who was in the room gets back in even if the room is now full or draining. The server keeps their seat for its reconnect grace, 30 seconds by default.

A player whom an operator removed from the room in Game Rooms can't rejoin it. A room session does all this for you.


Leave

Close your connection to the server; with a room session, call LeaveAsync. Leave the room's groups with UnsubscribeGroupAsync. The server tells PlayServ the seat is free.


Next steps

Last updated on 22 Oct 2026