question

citato avatar image
citato asked

Best practice for interact with multiplayer server

Hello, I am building a multiplayer game with Photon Fusion. To avoid any hack, I want to host my server build on PlayFab Multiplayer Servers. My idea as below

- When client create room, I will call RequestMultiplayerServer from Cloud script to start a server build on PlayFab VM, create a Photon room with a Server right

- The client create room will join that room as a Client.

But I want to send room name to Server build to set the name to room when I start server, I also want to send error info when fail to create room from Server build on PlayFab to CloudScript to notify to the Client build.

Do we have any sample/best practice for my case? Can we send param to Server when RequestMultiplayerServer?

Thank you a lot.

CloudScriptCustom Game Serversmultiplayerphoton
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

>> Can we send param to Server when RequestMultiplayerServer?

You can refer to the API documentation - Multiplayer Server - Request Multiplayer Server - REST API (PlayFab Multiplayer) | Microsoft Docs to send the parameters to server instances through configuring them in the SessionCookie. Then, you can get the SessionCookie you send to the server instances by GSDK you integrated with the server before. You can check this section - Getting configuration settings within your game server to learn about how to get the SessionCookie using GSDK.

>> I also want to send error info when fail to create room from Server build on PlayFab to CloudScript to notify to the Client build.

After you call the API RequestMultiplayerServer and PlayFab VM agent fails to allocate the server instances, you can get the failed reasons in the error message of the API response, you can handle the error and return the failure information to players using CloudScript.

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.

citato avatar image citato commented ·

Thank you for you reply.

I checked SessionCookie and I think it is a solution for my case.

>> you can get the failed reasons in the error message of the API response

I think this only can report error message when allocate the server instances. For example: if client A want to create room name "RoomA", I use cloud script to request a multiplayer server on PlayFab and create "RoomA" by that server. The multiplayer server allocated successful but can not create "RoomA" (because that name is not available). So, how can I report to clientA that the create room command is fail because of the name.

0 Likes 0 ·
Sarah Zhang avatar image Sarah Zhang citato commented ·

As you said, the error messages returned by our API - RequestMultiplayerServer can only tell you why the server instance doesn't be allocated successfully.

For clarification, you can write any custom server-side logic in the CloudScript functions, you can define your custom error messages in the CloudScript functions. If someone submits an unavailable parameter, you can return your custom error messages to the client directly.

1 Like 1 ·

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.