Documentation
Ask or search…
K
Links
Comment on page

Game Manager

Overview

Hosts must periodically send a heartbeat request within the lobby's default 30-second active lifespan. Failure to update or send a heartbeat marks the lobby as inactive. Inactive lobbies are automatically filtered out of queries based on the lastUpdated field. You can override this filter by including a LastUpdated filter to include inactive lobbies in query results.
Here's example code snippet that demonstrates sending a heartbeat via the Update function in GameManager.
// Assets/SurvivalEngine/Scripts/Tashi/TashiGameManager.cs
async void LobbyUpdating()
{
var outgoingSessionDetails = NetworkTransport.OutgoingSessionDetails;
var updatePlayerOptions = new UpdatePlayerOptions();
string lobbyId = LobbyManager.Get.SerializeFieldLobby.Id;
if (outgoingSessionDetails.AddTo(updatePlayerOptions))
{
await LobbyService.Instance.UpdatePlayerAsync(lobbyId, LobbyManager.Get.PlayerId, updatePlayerOptions);
}
if (LobbyManager.Get._isLobbyHost)
{
var updateLobbyOptions = new UpdateLobbyOptions();
if (outgoingSessionDetails.AddTo(updateLobbyOptions))
{
await LobbyService.Instance.UpdateLobbyAsync(lobbyId, updateLobbyOptions);
}
}
}
// Assets/SurvivalEngine/Scripts/Tashi/TashiGameManager.cs
async void ReceiveIncomingDetail()
{
if (NetworkTransport.SessionHasStarted) return;
Debug.LogWarning("Receive Incoming Detail");
string lobbyId = LobbyManager.Get.SerializeFieldLobby.Id;
var lobby = await LobbyService.Instance.GetLobbyAsync(lobbyId);
var incomingSessionDetails = IncomingSessionDetails.FromUnityLobby(lobby);
if (incomingSessionDetails.AddressBook.Count == lobby.Players.Count)
{
Debug.LogWarning("Update Session Details");
NetworkTransport.UpdateSessionDetails(incomingSessionDetails);
}
}
In the Update function, we call UpdateNetwork.
//Assets/SurvivalEngine/Scripts/Tashi/TashiGameManager.cs
private void Update()
{
UpdateNetwork();
}

Guide

  1. 1.
    In the BlankMap scene, create the GameManager object.
  2. 2.
    This object will facilitate the synchronization of data across clients.