A real-time multiplayer game platform built with C# and WebSockets, supporting multiple concurrent game rooms and turn-based gameplay.
This project is a WebSocket-based multiplayer game server that manages real-time communication between clients, game state synchronization, and room-based matchmaking.
The system is designed to support multiple simultaneous game sessions, with isolated room state and server-side validation to ensure correct gameplay. While the initial implementation includes Tic-Tac-Toe and Rock-Paper-Scissors, the architecture allows additional games to be added with minimal changes.
This project was built to explore real-time communication, server-side state management, and concurrency in a multiplayer setting.
Key goals included:
- Managing multiple concurrent game rooms
- Maintaining authoritative server-side game state
- Supporting low-latency, bidirectional communication
- Designing extensible game logic for additional game types
- Learn more about the C# developement process
- WebSockets are used for real-time, bidirectional communication
- Clients are assigned to rooms, each with isolated game state
- A centralized game handler validates moves and enforces turn order
- Game logic is abstracted to allow multiple game implementations
-
Program.cs
Application entry point; configures static file serving and initializes the WebSocket server -
WebSocketHandler.cs
Manages client connections, message handling, and routing messages to the appropriate room -
RoomHandler.cs
Tracks active game rooms, player membership, and room-level state -
GameHandler.cs
Defines the base game interface and implements game-specific logic (e.g. Tic-Tac-Toe) -
WebGames.Tests/
Unit tests for core game logic using xUnit
- .NET SDK 9+
dotnet runThe server will start on a local port (printed in the console). Open the client in a browser to connect and begin a game session.
Unit tests were written using xUnit To run them:
dotnet testTests were made to validate the game logic and state transistions independently of the WebSocket layer
- The server acts as the authoritative source of truth for all game state
- Clients only send intents (moves), not direct state mutations
- The architecture is designed to be extended to additional game types
This project was originally developed as part of a university course, but improvements and extensions are welcome.
Potential areas for extension:
- Additional multiplayer games
- Redo on the UI / UX of the front-end display
- Improved matchmaking