…
|
||
---|---|---|
.. | ||
src | ||
Directory.Build.props | ||
Presence.sln | ||
PresenceService.svg | ||
README.md | ||
screenshot.png |
README.md
languages | products | page_type | name | urlFragment | description | |||
---|---|---|---|---|---|---|---|---|
|
|
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.
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:
- Download and unzip the sample.
- In Visual Studio (2022 or later):
- On the menu bar, choose File > Open > Project/Solution.
- Navigate to the folder that holds the unzipped sample code, and open the C# project (.csproj) file.
- Choose the F5 key to run with debugging, or Ctrl+F5 keys to run the project without debugging.
- From the command line:
- Navigate to the folder that holds the unzipped sample code.
- 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