🚀 WebSocket Server

Real-time Team Communication Platform

📖 Overview

This WebSocket server enables real-time bidirectional communication between two teams. It provides a robust messaging system where Team 1 and Team 2 can send messages to each other through a centralized server that handles routing and message delivery.

✅ Server Status

Deployed at: wss://akshit-wsserver.workaround.besten.space

🎯 Quick Start

Get started by opening the team clients in separate browser tabs:

Team 1

Purple-themed interface for Team 1 members

Open Team 1 Client

Team 2

Pink-themed interface for Team 2 members

Open Team 2 Client

💡 Tip

Open both clients side-by-side or in separate browser windows to test the real-time messaging functionality.

🔧 How It Works

1. Connection & Registration

When a client connects to the WebSocket server, it must first register as either Team 1 or Team 2 by sending a registration message:

{ "team": 1 // or 2 for Team 2 }

2. Message Format

After registration, teams can send messages using the following payload structure:

Message Payload Structure

{ "from": 1, // Integer: Sender's team ID (1 or 2) "to": 2, // Integer: Recipient's team ID (1 or 2) "message": "hi" // String: The message content }

3. Message Routing

The server performs the following validations:

  • Verifies that the from field matches the sender's registered team ID
  • Validates that the to field is either 1 or 2
  • Checks if the target team is currently connected
  • Routes the message to the appropriate recipient

✨ Features

🔐 Team Registration

Secure team identification and connection management

📨 Message Routing

Intelligent message routing between teams with validation

🔄 Auto-Reconnect

Automatic reconnection on connection loss

💬 Real-time Updates

Instant message delivery with status notifications

🎨 Team-Specific UI

Beautiful, distinct interfaces for each team

⚡ Error Handling

Comprehensive error messages and validation feedback

📝 API Reference

Registration Message

// First message after connection { "team": 1 // Required: 1 for Team 1, 2 for Team 2 }

Send Message

// Send message to another team { "from": 1, // Required: Your team ID "to": 2, // Required: Target team ID "message": "hi" // Required: Message content }

Server Responses

The server sends different response types:

// Status message { "type": "status", "data": "Team 1 registered successfully" } // Incoming message { "type": "message", "from": 1, "to": 2, "message": "Hello from Team 1!" } // Error message { "type": "error", "data": "Team 2 is not connected" }

⚠️ Error Handling

Common Errors

  • Team not registered: Send registration message first
  • Team ID mismatch: The from field must match your registered team
  • Target team not connected: The recipient team must be online
  • Invalid JSON: Ensure proper JSON formatting

🔗 Technical Details

WebSocket Protocol

The server uses the WebSocket protocol (WSS for secure connections) for real-time bidirectional communication. This allows for low-latency message delivery without the overhead of HTTP request-response cycles.

Connection Endpoint

wss://akshit-wsserver.workaround.besten.space

Supported Features

  • Multiple concurrent team connections
  • Automatic connection cleanup on disconnect
  • Message validation and error reporting
  • Status notifications for all operations