question

vastchen avatar image
vastchen asked

How do I activate the server?

My CloudScript needs to find the best server to tell the client, but if the server is not active I can't get the SessionId, and I can't get the IP prot

10 |1200

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

Rick Chen avatar image
Rick Chen answered

You could use the RequestMultiplayerServer API to activate a multiplayer server. On CloudScript, there is a predefined variable call “multiplayer”, you could use “multiplayer.xxx” to call the Multiplayer API on CloudScript. For example,

handlers.RequestMultiplayerServer = function(args, context)
{
    
            return multiplayer.RequestMultiplayerServer (args);
}


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.

vastchen avatar image vastchen commented ·

Thank you, but I'm looking at the RequestMultiplayerServer documentation and I see that it still needs a SessionId, but my server is not active. How do I get the SessionId?I tried to generate a GUID myself, but it didn't work,It was wrong:"PlayFab API request failure",Please help me thank you

request={"PreferredRegions":["EastUs"],"SessionId":args["SessionId"],"BuildId":g_gameServerBuildID};server = multiplayer.RequestMultiplayerServer(request);
0 Likes 0 ·
vastchen avatar image vastchen commented ·

I tried BuildAliasParams again and the parameter still doesn't work

0 Likes 0 ·
vastchen avatar image
vastchen answered

@Rick Chen Thank you, but I'm looking at the RequestMultiplayerServer documentation and I see that it still needs a SessionId, but my server is not active. How do I get the SessionId?I tried to generate a GUID myself, but it didn't work,It was wrong:"PlayFab API request failure",Please help me thank you

request={"PreferredRegions":["EastUs"],"SessionId":args["SessionId"],"BuildId":g_gameServerBuildID};
server = multiplayer.RequestMultiplayerServer(request);
10 |1200

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

Dimitris-Ilias Gkanatsios avatar image
Dimitris-Ilias Gkanatsios answered

The session ID is a value you have to generate yourself and is related to the unique session of the game. Feel free to check our quickstart video for further details (19) PlayFab Multiplayer Hosted Servers part 1: Multiplayer Servers Quick Start - YouTube

10 |1200

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

vastchen avatar image
vastchen answered

Here is my summary in the hope of helping the newcomers:


RequestMultiplayerServer :

The actual intention is to activate a new server.

It will not return the currently active server and the document address is 404:

https://docs.microsoft.com/zh-cn/gaming/playfab/features/multiplayer/servers/mps-allocator-sample

The prerequisite is that the number of active servers is smaller than the number of standby servers.

Usage:

let Regions = ["EastUs"];

multiplayer.RequestMultiplayerServer({"PreferredRegions":Regions,"BuildId":g_gameServerBuildID,"SessionId": NewGuid });


playfab-1.png (145.8 KiB)
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.