Chat

This document outlines the socket events, payloads, and workflows for the Chat feature

Overview

The chat system is room-based, supporting real-time messaging, user lists, and moderation commands. It uses socket.io.

Connection

Rooms

The following rooms are currently allowed:

  • English

  • Turkish

  • French


Client -> Server Events

These are events emitted by the frontend to the backend. You emit these events.

1

join-room

Joins a specific chat room.

  • Payload:

{
    "room": "English" // or "Turkish", "French"
}
  • Behavior:

    • Validates the room name.

    • Sends back the recent history via get-messages.

    • Adds user to the online list for that room.

    • Broadcasts updated online-users counts to all clients.

  • Rate Limit: Yes (Default)

2

send-message

Sends a message to the current room.

  • Payload:

{
    "room": "English",
    "message": "Hello world!"
}
  • Behavior:

    • Validates auth, room, and message length (max 256 chars).

    • Checks for muted or banned status.

    • Checks for Admin/Mod commands (e.g., /mute, /ban).

    • If successful, broadcasts the message via message-response.

  • Rate Limit: 2000ms (approx)

  • Restrictions:

    • Max length: 256 characters.

    • User must not be muted or banned.

  • Payload (Error/Notification):

{
    "status": false,
    "room": "English",
    "message": "You are sending messages too fast" // or "You are muted...", "Please wait..."
}
3

online-users

Requests the current count of online users per room.

  • Payload: None

  • Behavior: Server responds with online-users event containing counts.

4

get-online-users

Requests the list of specific users in the current room.

  • Payload: None

  • Behavior: Server responds with online-users-list containing user details.


Server -> Client Events

These are events emitted by the backend to the frontend. You need to listen to these events.

1

message-response

The primary event for incoming messages, errors, and system notifications.

  • Payload (Success/Broadcast):

Note: The output is an array of message objects. When a new message comes in, the server currently sends the specific array (often containing the history + new message).

2

get-messages

Sent immediately after joining a room to load chat history.

  • Payload:

3

online-users (Broadcast)

Updates the counts of users in each room. Includes "fake" inflation counts.

  • Payload:

4

online-users-list

Response to get-online-users.

  • Payload:


Data Models

Message Object


Moderation Commands

Available to users with role: "mod" or "admin".

Command
Usage
Description

/mute

/mute [steamid] [duration]

Mutes a user. Duration format: 10s, 5m, 2h, 1d.

/ban

/ban [steamid]

Bans a user from the specific feature/site.

/unmute

/unmute [steamid]

Unmutes a user.

/unban

/unban [steamid]

Unbans a user.

Examples:

  • /mute 76561198000000001 1h

  • /ban 76561198000000001