Create a multiplayer game

Introduction

The Stormancer SDK provides a common workflow that can be used by most games to implement: - Authentication, including integration with Steam, XBox Live and PSN. - Party management - Game finding capabilities (with customizable ways of locating the player session.) - Game session management.

For reuse and modularity, the core Stormancer client and server library only provide low level features such as:

  • Client/server connection establishment with endpoint sniffing and reconnection to another node in the server farm in case of failure.

  • Security features (player session identification, encryption)

  • Transparent P2P networking including relay and Nat traversal

  • Asynchronous task based remote procedure calls and fire&forget messaging (both reliable and unreliable)

  • Transparent message routing

  • Etc…

The SDK provides higher level features as server and client plugins that can be added to Stormancer applications. The core client library supports detecting the presence or absence of serverside plugins to enable the corresponding high level APIs.

Example: P2P workflow

../_images/P2P-workflow.png

Enabling plugins

In server applications, enabling plugins is often as simple as either importing a Nuget package or putting the plugin directory in the server application Git directory.

On clients, plugins are not automatically enabled. To do that, they must first be added to the project includes, then enabled in the client configuration.

//Create a configuration object to connect to the application samples/p2p on the test server gc3.stormancer.com
    auto config = Stormancer::Configuration::create("https://server", "samples", "p2p");

    //Add plugins used by the application
    config->addPlugin(new Stormancer::AuthenticationPlugin());
    config->addPlugin(new Stormancer::GameFinderPlugin());
    config->addPlugin(new Stormancer::GameSessionPlugin());
config->addPlugin(new Stormancer::PartyPlugin());

The most powerful way to add custom online features to games is to create a plugin . For more information on the subject, please read the related article. This way, it’s easier to create only code that encapsulates connection, authentication and reconnection to provide APIs that are robust and easy to use.

Authenticating

Stormancer clients use UDP datagrams to communicate with the server farm and maintain a persistant session to the throughout gameplay with a 5s timeout by default. This behavior is quite different from what HTTP based services do: In this case the server is not easily able to track the client session in realtime.

The user plugin handles both authentication and session management, and supports cross cluster authentication and session access in a federation of server farms (clusters).

In Stormancer, users are primarely identified by their user id, a guid that uniquely identify a player on the platform. The plugin links user ids to:

  • Session ids: They identify a unique client instance session. For most game, it’s a game client session. As long as the client library instance is reused accross reconnections (recommanded), the session id survives them.

  • platform id: The platform id is a 2 member structures that contain the platform that was primarely used to authenticate the current user session (for instance steam) and the online id of the player on this platform (for instance the steamId of the player). If an user is linked to several platforms, the platform id provided changes when authenticating using the different platforms, while the user id stays the same.

  • user handle. The user handle is an optional friendly unique identifier that can be changed by players without impacting game operation. It’s constructed by letting the player specify an handle that must be more than 3 characters long and less than 32 characters, then appending a random 4 digits number that guaranties handle unicity (shyntae#3456, l0rd3v1l#4572)

Accessing profiles

We recommand using the profiles plugin to access player profile data. The plugin exposes profiles as a composition of parts. Parts can be provided by different game server components, and the client API supports both bulk get and filtering of parts according to keywords. By default, the user plugin provides an user part, but adding new parts if straightforward.

The profiles plugin also supports querying profiles by user handle prefix to search for players in the database.

Managing friends

friends plugin : documentation WIP

Joining a party

Player groups or parties are an important feature of most online games. Stormancer provides a scalable, realtime parties plugin that maintain a scene dedicated to the interaction of players inside the party. This scene can host additional logic, including chats, player state or messaging systems, or even gameplay logic.

By default, parties provide a set of useful capabilities, including:

  • Leader management

  • Replicated Party wide settings (only updated by the leader)

  • Replicated player settings (only updated by the player)

  • Simple ready system which automatically triggers the gamefinding process when all players in the party are ready, and cancels it if a player unsets the ready state.

Parties are completely independant from game sessions. A group of players created using the parties is maintained during the whole client session.

Integration with the Unreal OSS is provided to integrate with the platforms social features (Steam, XBoxLive, PSN…). As support for UE OSS is separated from the code plugin logic, it would be possible to add custom implementations directly targeting the platform APIs.

Finding a game

In Stormancer applications, the process of creating or joining game sessions is unified in the game finder plugin This highly extensible plugin enables the game to expose one or several named game finders of varied complexities.

Joining a game session

Once the game finder resolves a game, it’s possible to start the game session using any third party session system (steam, XboxLive, etc..). However, the SDK includes a gamesessions plugin that provides support for:

  • selfhosted logic : Run game server logic (gameplay or just message broadcasting) in the game session scene. This mode enables offload P2P or dedicated server connectivity & startup to another plugin than the game session plugin too.

  • P2P sessions : The game session plugin selects an host then establishes a P2P mesh with a star topology around the selected host.

  • Dedicated server sessions : The game session plugin starts a dedicated server as an external process and orchestrates client-server connectivity. Currently, local executable, docker API based containers, Amazon S3 VM and Amazon ECS containers are supported.

Additional plugins can be enabled on a gamesession scene to provide an higher level set of features to replace or complement the features included in the gamesession plugin.

Game session plugins

Plugins are available to add common features to gamesession scenes. - The messaging plugin provides an interface to send and broadcast messages to players in the game session. By default, it uses the server for broadcasting, but peer 2 peer messaging is possible too.

Additionnal use cases

Leaderboards

The leaderboard plugin manages leaderboards for the game. It uses Elasticsearch as a storage backend as well as scalable queries to support leaderboards of virtually any size. Supported features are:

  • Leaderboard navigation (previous/next page)

  • Fast and direct access to location of a player in a leaderboard

  • Both multiple leaderboards per Elasticsearch index or single leaderboard per index models depending on expected leaderboard size.

  • Custom data

  • Filtering by custom data

  • Filtering by user ids (for friends leaderboards)