question

David Pittman avatar image
David Pittman asked

Two questions about activating dedicated servers

We are prototyping a game with PlayFab multiplayer servers, and I'm struggling to understand what should be responsible for spinning up the servers.

The basic structure of the game is:

1. Players begin in a hub populated with, say, up to 32 players

2. From the hub, they matchmake into groups of 1-4 and migrate to a mission server

3. After the mission, they return to the hub (probably but not necessarily the same hub server they were on before)

The two immediate questions we are trying to answer are:

1. What is responsible for activating the hub servers, if not matchmaking?

2. How should a mission server be activated when 1 player wants to play solo (because matchmaking has a 2-player minimum)?

Thanks!

10 |1200

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

1 Answer

·
Sarah Zhang avatar image
Sarah Zhang answered

>> What is responsible for activating the hub servers, if not matchmaking?

PlayFab provides an API RequestMultiplayerServer for your use when you want to request a server session without using PlayFab Matchmaking. It only accepts entity tokens of the title by default. So we would recommend you call this API on a custom lobby server or PlayFab CloudScript via multiplayer.RequestMultiplayerServer method, then allocate the IP addresses and Port numbers to players on your own.

In addition, please check this documentation to learn about managing standing-by servers before you call RequestMultiplayerServer API to allocate servers. For more concepts about PlayFab game server, please feel free to check our documentation.

>> How should a mission server be activated when 1 player wants to play solo (because matchmaking has a 2-player minimum)?

As the first answer said, you can call the API RequestMultiplayerServer on CloudScript then let clients call ExecuteEntityCloudScript API to execute the function to get the corresponding server details. You can refer to the following CloudScript function example.

// This an example of a function that calls a PlayFab Multiplayer API. The function is called using the 
// 'ExecuteEntityCloudScript' API (https://api.playfab.com/documentation/CloudScript/method/ExecuteEntityCloudScript).
handlers.requestMutiplayerServer = function (args, context) {
    var apiResult = multiplayer.RequestMultiplayerServer({
        "BuildId": "[YourBuildId]",
        "SessionId": "[YourCUstomSessionId]",
        "PreferredRegions": [
            //Choose the preferred regions in need.
            "EastUs",
            "WestUs"
        ]
    });
    return apiResult;
};

2 comments
10 |1200

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

Denzie Gray avatar image Denzie Gray commented ·

@Sarah Zhang

Assuming I wanted to use apiResult in the code you wrote above and I didn't want to return the apiResult to the user:

1. Could I use it to send a message to the game server? If so how?

2. The GSDK mentions a heartbeat to keep the server alive - is this heartbeat reset if I call "RequestMultiplayerServer" on an active server

3. Should I assume that any server that goes inactive/standby no longer contains the previous gamestate?

0 Likes 0 ·
brendan avatar image brendan Denzie Gray commented ·

Since you also posted a new thread for 1, let's keep that discussion there, if you have follow-up questions: https://community.playfab.com/questions/47116/multiplayer-game-server-questions.html

For 2, the heartbeat is something the game server does as a result of your code running the update logic for the GSDK. The flow is that a server spins up in Standby mode (your code is not yet running, but the server is provisioned and running for your title), then when the server is requested by a matchmaking call or RequestMultiplayerServer, your code is executed. The heartbeat is the server telling PlayFab that it's running still. If it stops sending that for a couple of minutes, we have to assume the server stopped.

For 3, servers don't go back to standby. When your code exits, they are cleaned up. Any newly instanced server is "fresh".

0 Likes 0 ·

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.