How to notify MuiltyPlay that the game has started?

At present, after being distributed through MatchMaker, the Server will be opened
But after an hour, the server will be shut down,

This is very disturbing,
So here I want to ask how to notify the server that the game has started,
Don’t automatically forcibly close the game after an hour because you didn’t receive the allocation message.

public async void Start_MuiltyPlay()
{
    LogServerConfig();
    m_MultiplayEventCallbacks = new MultiplayEventCallbacks();
    m_MultiplayEventCallbacks.Allocate += OnAllocate;
    m_MultiplayEventCallbacks.Deallocate += OnDeallocate;
    m_MultiplayEventCallbacks.Error += OnError;
    m_MultiplayEventCallbacks.SubscriptionStateChanged += OnSubscriptionStateChanged;
    m_ServerEvents = await MultiplayService.Instance.SubscribeToServerEventsAsync(m_MultiplayEventCallbacks);

    if (!string.IsNullOrEmpty(MultiplayService.Instance.ServerConfig.AllocationId))
    {
        await StartGame();
    }
}
public async Task StartGame()
{
    matchmakingResults = await MultiplayService.Instance.GetPayloadAllocationFromJsonAs<MatchmakingResults>();

    string match_id = matchmakingResults.MatchId;

    Debug.Log("Fusion Sesion: "+ match_id);

    Photon_Manager.Instance.StartServer(match_id);

    while (!Photon_Manager.Instance.isConnect)
    {
        await Task.Delay(250);
    }

    ReadyingServer();
}
private async void ReadyingServer()
{
    await MultiplayService.Instance.ReadyServerForPlayersAsync();
    Debug.Log("ReadyServerForPlayersAsync");
}

Hello,

Could you provide a link to the server where you are seeing this behaviour?

Multiplay will know that the game has started once a server is allocated. However, there is a default timeout of 1 hour on an allocation. The support team can change this value for you.

We are evaluating ways to put the configuration of this value safely into the API and dashboard in the near future.

@danri
I provide the Log of the previous test,
These two times did not receive the Allocate event,
There should be server information in it for reference.

Yes, because it may be required early in the game,
Do a lot of stress testing on the server,
It would be much more convenient if we could test without interruption, thank you~

8657718–1165617–server_43024964_logs_20221213081514.zip (3.92 KB)
8657718–1165620–server_43024964_logs_20221213093041.zip (3.9 KB)

Thanks for the extra information.

I can see from our backend systems that your server is allocated correctly. I also see that from the latest log from server 43024964 that the server does have the correct allocation IDL

Server ID : 43024964
AllocationID : cef5b25f-f35e-4467-b6ed-2f491ebee819
Port : 9000
QueryPort : 9010
LogDirectory : 43024964/logs

So it seems like the allocate callback is partially working, or at least the server is able to get the allocation ID on startup from MultiplayService.Instance.ServerConfig.AllocationId.

My guess would be that the the Start_MuiltyPlay method is the problem here. Is that method being called by another MonoBehavior Start method somewhere else?

We recommend that the allocate callback is set up in the Start method, so it is as early as possible in the server lifecycle. See the docs for more info:

8658048–1165728–server_43024964_logs_20221213143216.zip (1.61 KB)

@danri

I am creating a MuiltyPlayManager in other code,

MuiltyPlayManager contains the Start_MuiltyPlay( ) method,

And it is indeed placed in Start( ),

So MultiplayEventCallbacks are placed directly in

Just in async void Start( )?

Loader.cs

MuiltyPlayManager.cs

will be modified

public async void Start()
{
    LogServerConfig();
    m_MultiplayEventCallbacks = new MultiplayEventCallbacks();
    m_MultiplayEventCallbacks.Allocate += OnAllocate;
    m_MultiplayEventCallbacks.Deallocate += OnDeallocate;
    m_MultiplayEventCallbacks.Error += OnError;
    m_MultiplayEventCallbacks.SubscriptionStateChanged += OnSubscriptionStateChanged;
    m_ServerEvents = await MultiplayService.Instance.SubscribeToServerEventsAsync(m_MultiplayEventCallbacks);

    if (!string.IsNullOrEmpty(MultiplayService.Instance.ServerConfig.AllocationId))
    {
        await StartGame();
    }
}

Thanks for the extra information. Your code looks correct, calling Start_Multiplay from the Start method should work.

I am going to ask the SDK development team about this, they will be able to give a more detailed answer.

I can’t speak towards the 1 hour timeout, as danri mentioned.
However, I can speak towards the potentially missed allocations:
The code:

    m_ServerEvents = await MultiplayService.Instance.SubscribeToServerEventsAsync(m_MultiplayEventCallbacks);

    if (!string.IsNullOrEmpty(MultiplayService.Instance.ServerConfig.AllocationId))
    {
        await StartGame();
    }

Reads to me that, if an allocation has not been done at startup, then “StartGame()” will not be called.
Do you also call StartGame() inside of your OnAllocate function?