question

umut34 avatar image
umut34 asked

How to understand if we are a matchmaking-allocated server instance?

Hello,

I wanna shut allocated servers down if no players succeed to connect in 30 seconds. Currently, they stay online forever with 0 players on them. I also have servers that use standby mode so I don't want to close any server that is not an allocated server.

I already use photon bolt's player connection/disconnection methods so I handle if a player joins and then quits. The server will shut down in such a scenario. But if no players can connect, and the server is allocated to wait for them, it doesn't know what to do.

In short;
If the server is allocated by a matchmaking queue, then it should wait 30 seconds and quit if no players join. But if it's a standby server, it shouldn't have a timeout. Can you please help me?

photonCustom Game ServersMatchmaking
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

umut34 avatar image umut34 commented ·

By the way, I tried using this method;

PlayFabMultiplayerAgentAPI.GetInitialPlayers()

but it returns null even if it's a matchmaking-allocated instance.

0 Likes 0 ·

1 Answer

·
Xiao Zha avatar image
Xiao Zha answered

According to your description, I think you needs is to shut down the server instance when there is no player connected after server instance active 30s. If so, you can:

1.Use PlayFabMultiplayerAgentAPI.CurrentState.CurrentGameState to check if the server is active.

2.If the server is active, you can use PlayFabMultiplayerAgentAPI.CurrentState.CurrentPlayers to check current connected players, you can refer to the code example MpsSamples/AgentListener.cs at main PlayFab/MpsSamples GitHub to find how to maintain a connected player list.

3.If no players connected after 30s, then you can call your Shutdown method.

Please let me know if there are any misunderstandings.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.