Orleans Chat Room sample
This sample uses Orleans Streaming to build a basic chat application. In this application, each client can:
- Set their name
- Join and leave a channel
- Send and receive messages in that channel
- List the channel members
- Display the channel's chat history
Each chat channel has a corresponding ChannelGrain
which is identified by the channel's name, and a stream which is identified by a Guid
generated by that grain. Clients connect to the ChannelGrain
for a channel and then subscribe to the stream identified by the Guid
returned from the IChannelGrain.Join
call.
Sample prerequisites
This sample is written in C# and targets .NET 9.0. It requires the .NET 9.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
.
Running the sample
First, start the server in one terminal window by executing the following:
dotnet run --project .\ChatRoom.Service\
Then, once the server has started, open one or more terminal windows and execute the following in each:
dotnet run --project .\ChatRoom.Client\
The clients will print instructions to the terminal which tell you how to interact with the sample.