Game server hosting support
Integrate different hosting solutions using Cloud Code modules to manage servers.
Read time 2 minutesLast updated 2 days ago
Multiplayer Services are compatible with many game server hosting providers to provide advanced multiplayer features. In combination with Cloud Code modules, you can allocate servers, create multiplayer sessions, and enable player backfilling.
Hosting with Cloud code modules
The matchmaker services within the Multiplayer Services SDK can use Cloud Code modules to allocate game servers and coordinate matchmaking results. Refer to the documentation on Hosting with Cloud Code modules for further details.Authentication
You must authenticate the server with a service account usingServerAuthenticationService.Instance.SignInWithServiceAccountAsyncBackfilling
If Matchmaker allocated the server, it's possible to automatically request new players to join to backfill empty slots. These empty slots could be due to players leaving the session or because Matchmaker quickly created the match to minimize matchmaking time:This code can start the backfilling process as soon as the session is created. Additionally, this code automatically starts the backfilling process when the session has one more empty slot. Backfilling requires having the "Matchmaker Backfill Admin" permission on your service account. Refer to Matchmaker Backfill Admin for the required Matchmaker backfill API permission.// Adapt session options to your game needs var sessionOptions = new SessionOptions(){ MaxPlayers = 2};// Add backfilling configuration if you want the session to automatically set up backfill when a player leaves.// This requires having the "Matchmaker Backfill Admin" permission on your service account.sessionOptions.WithBackfillingConfiguration( enable: true, automaticallyRemovePlayers: true, autoStart: true, playerConnectionTimeout: 30, backfillingLoopInterval: 1);
It's also possible to manually start and stop the backfilling process using the following code:
Starting and stopping the backfilling of a session can be useful if certain times aren't appropriate for players to be joining (for example, if the session is about to end, or if a cinematic is in progress). Refer to WithBackfillingConfiguration() for more information on the backfilling configuration.IServerSession session = await MultiplayerServerService.Instance.CreateMatchSessionAsync(matchId, sessionOptions);// Start the backfilling if it is not already in progressawait session.StartBackfillingAsync();/// Stop the backfillingawait session.StopBackfillingAsync();