Skip to content

Repository files navigation

Multiplayer Game Platform

A real-time multiplayer game platform built with C# and WebSockets, supporting multiple concurrent game rooms and turn-based gameplay.


Description

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.

Motivation

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

Architecture Overview

  • 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

Project Structure

  • 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


Running the Project

Prerequisites

  • .NET SDK 9+

Start the server

dotnet run

The server will start on a local port (printed in the console). Open the client in a browser to connect and begin a game session.

Testing

Unit tests were written using xUnit To run them:

dotnet test

Tests were made to validate the game logic and state transistions independently of the WebSocket layer

Notes

  • 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

Contributing

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

About

A real-time multiplayer game platform built with C# and WebSockets, supporting multiple concurrent game rooms.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages