Édition

Windows Runner C# sample

This tutorial lists the steps to get the sample set up ready for use with the PlayFab Multiplayer Servers.

Note

In order to use and view the PlayFab Multiplayer Servers, you need to enable the feature from Game Manager. For instructions, see Enable the PlayFab Server feature.

  1. Configure API feature option
  2. Create a PlayFab Multiplayer Game Server Build: Server set up
  3. Create servers by deploying a build
  4. Request multiplayer servers: Client set up. This is needed so you can start a client that connects to the servers

Configure API feature option

Note

This step is needed only for running this sample. You do not need to allow clients to start games unless your title requires this set up.

  • Log into your developer account on PlayFab.com to use the Game Manager portal
  • Select your game title
  • Select the settings icon > API features as shown in the image below.

API feature tab in Game Manager

  • Under Options, select Allow client to start games as shown in the image below.

Select allow client to start games in Game Manager

Server set up

Describes how to get the PlayFab Multiplayer Game Server Build.

  • PlayFab Game Server SDK of the PlayFab Multiplayer Server Build for the Windows Runner sample.

  • If you prefer to build this on your own:

    • Get the Windows Runner C# sample using standard Git methods or downloading this as a zip file.
    • Open the project using Visual Studio 2017 or later. This should automatically trigger dependencies like the latest PlayFab Game Server SDK (GSDK) nuget package to be downloaded.
    • Compile and build the WindowsRunnerCSharp.csproj in release x64 configuration. You would get a game server build that is integrated with the GSDK, making this a valid PlayFab Multiplayer Game Server Build.
    • Go to the bin folder and zip up all the x64 release binaries. There should be no internal folder structure, the zip file should be a simple flat collection of files, as shown in the image below.

    GSDK Sample Output

Tip

To cross-check, you can compare your build output with the compiled version provided in the link above.

When you have the zip file, you are ready to start deploying a build.

Create servers by deploying a build

You can deploy a build using one of the following methods.

For some settings, it may be easier to configure using the web interface—Game Manager.

Next, set up and run the client to connect to the deployed servers.

Client set up

Describes how to get the Windows Runner client application to connect to the game servers you've created using PlayFab Multiplayer Servers. This can only be set up after you have servers in standby.

  • After deploying a build, wait for standby servers to be available

  • Get the titleId and buildId of the build

    • Using Game Manager:

      • Go to My Studios and Titles page and look for your game title. Copy the ID value listed there and paste it somewhere convenient that you can access later. This is the titleId
      • Select the game title to view the dashboard
      • Go to Multiplayer > Servers > Builds
      • Copy the ID for the build you want to use and paste it somewhere convenient. This is the buildId
    • Using PowerShell, this information is in the output after the build is deployed successfully.

      • Copy the titleId and buildId and paste it somewhere convenient
  • Get the Windows Runner C# sample using standard Git methods or downloading this as a zip file. Skip if you have done this earlier.

  • Open the project using Visual Studio 2017 or later. This should automatically trigger dependencies like the latest Game Server SDK nuget package to be downloaded.

  • Compile and build the WindowsRunnerCSharpClient.csproj in release x64 configuration

  • Open Command Prompt and navigate to the output folder of this project

  • Run the WindowsRunnerCSharpClient using this command line, replacing <TitleId> and <BuildID> with the values above: dotnet WindowsRunnerCSharpClient.dll --titleId <TitleId> --buildId <BuildId>

Example:

cd C:\Users\UserName\Documents\GitHub\MpsSamples\WindowsRunnerCSharp\WindowsRunnerCSharpClient\bin\Release\netcoreapp3.1

dotnet WindowsRunnerCSharpClient.dll --titleId CBE66 --buildId 36083326-3bd5-4b8f-a97d-7e82f066aa40 --verbose

When the client successfully connects to the server, the Command Prompt would display a log message informing you that a server is allocated with an IP address.

See also