samples/orleans/Presence
..
src
Directory.Build.props
Presence.sln
PresenceService.svg
README.md
screenshot.png

README.md

languages products page_type name urlFragment description
csharp
dotnet
dotnet-orleans
sample Orleans Gaming Presence service sample orleans-gaming-presence-service-sample An Orleans sample service demonstrating the use of the Gaming Presence service.

Orleans Gaming Presence service sample

This sample demonstrates a gaming presence service in which a game server (represented by the LoadGenerator application) sends periodic heartbeats to a cloud service (represented by the PresenceService application) containing the status of a game which it is hosting. Inside the service, a corresponding PresenceGrain is responsible for unpacking the heartbeat message and reflecting the state of the game in the PlayerGrain and GameGrain grains. The effects of this can be seen on a client application (PlayerWatcher), which polls the player for the current game session. Each time a new game session is returned, the client creates a new LoggerGameObserver which subscribes to the game grain so that status updates are pushed to it using the IGameObserver interface.

A visual representation of the above text

Sample prerequisites

This sample is written in C# and targets .NET 8.0. It requires the .NET 8.0 SDK or later.

Building the sample

To download and run the sample, follow these steps:

  1. Download and unzip the sample.
  2. In Visual Studio (2022 or later):
    1. On the menu bar, choose File > Open > Project/Solution.
    2. Navigate to the folder that holds the unzipped sample code, and open the C# project (.csproj) file.
    3. Choose the F5 key to run with debugging, or Ctrl+F5 keys to run the project without debugging.
  3. From the command line:
    1. Navigate to the folder that holds the unzipped sample code.
    2. At the command line, type dotnet run.

To build and run the sample step-by-step on the command line, use the following commands:

Build the solution using the .NET CLI:

dotnet build

Launch the server process:

dotnet run --project ./src/PresenceService

In a separate terminal window, launch the player watcher:

dotnet run --project ./src/PlayerWatcher

In a separate terminal window, launch the load generator:

dotnet run --project ./src/LoadGenerator