question

louisyeow avatar image
louisyeow asked

Need custom server suggestion and clarification

I am new and need advise and suggestion on custom server, please bear with me. The game is sort of like room-based poker where the maximum player per room is 5. Here's my questions:

1. Currently I am writing the game server to run as a room per server instance,
is this the recommended approach for this kind of game ? or would it be better to write a game lobby
to cater for like 500 players and segregate the network messages to individual game room? How about the
$$ charges differences if any on both approaches?

2. When matchmaking the client has to specified the region, how to get the best region for a client ?
Geolocation info to determine the client region ?

10 |1200

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

brendan avatar image
brendan answered

For 1, in general it's more efficient to have the server instance handle a higher number of players. Your mileage may vary, of course, as it may be simpler to eat the extra memory cost associated with spinning up an instance per game session, but for games where you only use a small amount of CPU per session, it would make sense to maximize the number of players per instance. But as to the cost, that's solely determined by the number of servers you're running and your total data egress (mostly the former).

For 2, yes, use the geolocation info from the login event, or just ask the player where they are (or let them choose a region).

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.

louisyeow avatar image louisyeow commented ·

Brendan,

Thanks for your valuable input. I will take your advise and change the server to act like a lobby to accomodate 500 players per instance (might be lower because I might put voice chat integration in) and segregate/"channelize" the network messages to differentiate each room.

I need some clarifications though.

1. In order for a player to join a specific playing friend room, he needs to know the lobby Id (game server instance id), the room id and password (if it is private room) of his friend is playing.So during matchmaking only the lobby id will be used and (a) Playfab would be able to locate the lobby id (instance id) even if the players are from different regions ? (b) Then the room and password info would be sent as payload of my client message to my lobby server for further matchmaking check, correct ?. (c) What's the method to save the lobby id, room id and password (if applicable) - UpdateUserReadOnlyData when the user RedeemTicket successful at my lobby server?

0 Likes 0 ·
brendan avatar image brendan louisyeow commented ·

Yes, finding the number of players you'll want to have max per instance will take a bit of experimentation.

For your specific questions:

a) Yes, if you specify a Lobby ID, you'll be returned a ticket for that specific instance, irrespective of what region it's in, what Build ID it is, or what Game Mode it's running.

b) If you're using a room/password system, since that's not part of the PlayFab matchmaker, yes, you would need to send that to the client somehow, and the client would need to send it to your server, if the server doesn't already know about the player.

c) Are you looking at saving the Lobby ID (which should be transient - only while that instance is running, and it's best to not have an instance run forever)? You can save it to player data or an Entity Object, but where is that data coming from to start? Under what circumstances would the player need it again later?

0 Likes 0 ·
louisyeow avatar image
louisyeow answered

Thanks again for your valuable input. I presume the lobby id is sort of the local process id in the running machine + other info to make it works with AWS/Azure etc and manage by Playfab management tools and one of advantage is to able to make it appears "regionless" with the Lobby Id. :)

I do need the Lobby Id for the scenario where a player invite his friends to his private room. Let me clarify my intention:

There are 2 type of room, for public a player would be randomly put into any non-private available room or if non found a new public room will be created. For private it is created by a player and invite his friends to play together (password + room number would be send via messaging)

Here's the pseudocodes of what I am doing:

CLIENT: 3 scenerios:
1. Public Room - PlayfabClientAPI.MatchMake with Region, StartNewIfNoneFound
2. Create Private Room - PlayfabClientAPI.MatchMake with Region, StartNewIfNoneFound
3. Join A Friend in Private Room - GetUserReadOnlyDataAsync for the Friend Lobby Id, then PlayfabClientAPI.MatchMake with LobbyId

Assume the host/port are valid and a client is connected

SERVER:

1. RedeemMatchmakerTicketAsync if successful
2. - If (1) successful, Password check (if applicable) ,room availability etc would be run and the player would be put into a room (new or join)
- If (1) Failed, send connection failed to client, disconnect client. Refer to the Disconnection/Player left part..
3. If (2) successful, Save the lobby Id (get from command line arg) to the player.with PlayfabServerAPI.UpdateUserReadOnlyDataAsync. Though only client scenerio (3) used the LobbyId, I just saved it for all for consistency and lesser conditional checking :P

Disconnection or player left

SERVER:

1. NotifyMatchmakerPlayerLeftAsync
2. PlayfabServerAPI.UpdateUserReadOnlyDataAsync with KeysToRemove = new List<string> {"LobbyId"} to remove the lobbyd info from the leaving player

You input is very much appreciated on anything deems fit :)

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.

brendan avatar image brendan commented ·

The Lobby ID is simply a unique identifier for the instance of the game running on a server host machine.

The logic you've described seems fine - let us know if you run into any issues.

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.