Skip to content

rudyroggio/websocket-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

WebSocket Game Server

Lightweight WebSocket game server built with Rust, designed for managing multiplayer game sessions with real-time scoring.

Running the Server

Start the server:

cargo run

The server will start on localhost:3001

API Endpoints

  • GET /health - Health check endpoint
  • GET /ws - WebSocket connection endpoint

WebSocket Events

Client to Server

  1. Create Game
{
    "event": "createGame",
    "playerName": "Player1"
}
  1. Join Game
{
    "event": "joinGame",
    "code": "GAMECODE",
    "playerName": "Player2"
}
  1. Start Game
{
    "event": "startGame"
}
  1. Submit Solution
{
    "event": "submitSolution",
    "usedHint": false
}

Server to Client

  1. Game Created
{
    "event": "gameCreated",
    "gameCode": "ABC123"
}
  1. Player Joined
{
    "event": "playerJoined",
    "players": [
        {"name": "Player1", "score": 0},
        {"name": "Player2", "score": 0}
    ]
}
  1. Game Started
{
    "event": "gameStarted"
}
  1. Scores Updated
{
    "event": "updateScores",
    "players": [
        {"name": "Player1", "score": 1},
        {"name": "Player2", "score": 0}
    ]
}

About

lightweight rust websocket

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published