question

ashoulson avatar image
ashoulson asked

Custom Server Order of Operations

Hi there,

I'm trying to work out a simple demo for a plain (non-Unity) C# custom server using PlayFab. I've seen the Unity server demo, but unfortunately I'm not getting much from it. The use of IoC makes it very difficult to determine the order of operations, and the accompanying tutorial is more geared towards how to use that particular server implementation than how that server is using the PlayFab API. Similarly, the custom game server tutorial page doesn't cover the information I'm looking for.

Is there a list somewhere of the actions my server should take on startup to make it available for PlayFab matchmaking and to receive clients? In particular, I'd like to know what my server is expected to do:

- On startup

- When a player connects directly (and what information is expected from the player)

- When a player leaves

- On shutdown

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

·
Brent Batas (Lisk) avatar image
Brent Batas (Lisk) answered

Hi ashoulson, I just started learning PlayFab, too, and I'll give it my best shot based on my limited understanding.

But I think conceptually you'd do something like...

1. Add the PlayFab C# SDK to the game server.


2. Call PlayFab's RedeemMatchmakerTicket and NotifyMatchmakerPlayerLeft in the game server when a player connects.


3. Upload the game server .exe to PlayFab in the Builds tab


4. Add the PlayFab C# SDK to the game client


5. Call Matchmake from the client. PlayFab will return some connection info (server IP, port, etc. + session ticket)


6. Have the game client connect to the game server located via the connection info from (5)

--- You'd do this via whatever networking protocol your C# server/client decide to use.


7. The server will validate the session ticket by calling something like PlayFabServerAPI.RedeemMatchmakerTicketAsync. If it checks out, acknowledge that the client is connected and start sending information. Call the PlayFab methods from step (2) to notify the PlayFab matchmaker of the transaction, so that it can be removed from the matchmaking pool.

8. When the game server is shutdown, PlayFab's system will automatically notice and will clean up and output logs/output files.

As for when a player leaves, that sounds like something your server just handles?

3 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.

brendan avatar image brendan commented ·

Yep, pretty much. The thing I would add is, please make sure to tell us when the player leaves via https://api.playfab.com/Documentation/Server/method/NotifyMatchmakerPlayerLeft.

But let me make sure: @ashoulson - do you mean a server hosted in our service, or an external server? If it's the latter,we just added support for that. Here's the tutorial: https://api.playfab.com/docs/external-server-hosting

1 Like 1 ·
ashoulson avatar image ashoulson brendan commented ·

Thanks! This would be for a custom server package uploaded to PlayFab and run on PlayFab's service.

Do I have to call RegisterGame or DeregisterGame if PlayFab is responsible for creating the host? Otherwise, as I understand it, all I do is call RedeemMatchmakerTicket when a player connects, and NotifyMatchmakerPlayerLeft when a player leaves. Is that correct?

0 Likes 0 ·
brendan avatar image brendan ashoulson commented ·

Ah, okay. In that case, it's just the first paragraph of what I said above. And no, RegisterGame and DeregisterGame are specifically for externally hosted servers. You're correct that you would just use RedeemMatchmakerTicket and NotifyMatchmakerPlayerLeft.

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.