question

entelicon avatar image
entelicon asked

Custom Server

I'm somewhat confused on creating a custom server.

My goal is to be able to call RedeemMatchmakerTicket from the server.

What qualifies for something to be considered a server? To me, building a Unity exe and calling it a server sounds fine. I noticed that RedeemMatchmakerTicket has to be called on the server, but the class 'PlayFabServerAPI' does not exist because it has #if ENABLE_PLAYFABSERVER_API, so when I am creating the server build where do I enable this?

And if you could explain how to use RedemMatchmakerTicket in conjunction with the server that would be amazing. Thanks in advance.


Custom Game Servers
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

·
brendan avatar image
brendan answered

Since you're a Unity developer, you could start off with our example game server - https://github.com/PlayFab/PlayFabGameServer. It shows all the basics of getting the user into the session and can be used as the core of your own server (it's actually used by a few live games).

But in short, a custom game server is a distinct executable you build with the server API enabled. You would run this server in our server hosting or another hosting provider (either works fine) so that players can connect to it. It's important that this never be distributed to any players, since a server requires a Secret Key for your title, which provides access to the Server and Admin API calls.

Here's a write-up of custom game servers, which includes information on using the RedeemMatchmakerTicket call: https://api.playfab.com/docs/custom-game-servers.

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

entelicon avatar image entelicon commented ·

I just went through all the documentation that you gave me.

It left me more confused then when I started. Is the project 'PlayFabGameServerClientExample''s code wrote to support 'GameServerSource' code because it did not seem like anything was linked together. I couldn't find an example of calling a function on the server the fired RedeemMatchmakerTicket and returned that response back to the client and if I did I overlooked it.

Also ~ Is this the general way to setup custom servers? Do you recommend any learning sources if I wanted to make all of this from scratch? I think my major problem is not actually knowing what has to go into a server for it to work properly. It makes sense to me to be able to call a function on the server and have that return a value back to the client, but obviously it's not that simple which is why knowing how all of this works would probably help me. Thanks!

0 Likes 0 ·
brendan avatar image brendan entelicon commented ·

In the GitHub repo, PlayFabGameServerClientExample is the example client application that connects to the game server. The server example is the project in GameServerSource. The PlayFabGameServerClientExample code shows using Matchmake() to get the info for a game server session and joining it, while the GameServerSource shows managing a player once it makes a connection to the server. The server, in this code, demonstrates kicking off the authentication in the OnAuthenticateConnection logic here: https://github.com/PlayFab/PlayFabGameServer/blob/6ca087454d00c3271fd14ba07fd7c35274283a2f/GameServerSource/Assets/Packages/DefaultPackages/UnityNetworkingContext/Mediator/UnityNetworkManagerMediator.cs.

Server code is definitely not trivial. If this isn't something you've worked on previously, I would highly recommend bringing an experienced server developer into your team.

0 Likes 0 ·
entelicon avatar image entelicon brendan commented ·

Is dependency injection the standard/required for creating a server?

0 Likes 0 ·
Show more comments

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.