Exercise Aspire MOG
Exercise Aspire Multiplayer Online Game
Create a new Application for playing a two-player browser game. We will use Dotnet Aspire to create different services that act together. In the first part, we will focus on the web application part of it, without dealing with different services in Aspire. Nevertheless, start by creating a new Aspire Solution, using the .NET Aspire Starter Application Template.
We will have to solve the problem to connect 2 clients to play one game. The process goes like this:
- Client 1 goes to a webpage where it can connect to a game.
- Client 1 waits until another player is matched to play the game with.
- Client 2 goes to a webpage where it can connect to a game.
- When two players are matched, the matchmaking service will create a game controller that handles the game state for this particular game instance.
- Both clients are assigned to the game controller.
- The game will start.
It is recommended to use Blazor Server for that, since we automatically get a websocket connection for each client that we can use to update the clients’ state.
Connect to a game:
Wait to be matched:
Play the game:
Use Blazor Canvas to render the game.