Lobby System Documentation

A complete technical guide to the BlinkBox Lobby System, including client-side Unity components and the Node.js backend server.

Overview

The BlinkBox Lobby System is a robust, multiplayer lobby solution designed for Unity games. It bridges the gap between Unity clients and a centralized backend to manage parties, matchmaking, and real-time state synchronization.

Party Management

Complete party system with Create, Join (via code), Leave, and Kick functionality. Synchronizes ready states and character selections in real-time.

Node.js Backend

Scalable Express.js + WebSocket server that handles connection management, heartbeats, and party logic independent of the game server.

Voice Chat

Integrated ODIN SDK support for high-quality voice chat, including Push-to-Talk, spatial audio, and mute functionality.

Modular UI

Prefab-based UI system with separate panels for Party, Join, and Connection states. Includes player nameplates and dynamic status indicators.

Installation & Setup

1. Unity Client Setup

  1. Ensure Photon PUN2 is installed and configured in your project.
  2. Import the ODIN SDK for voice chat functionality.
  3. Drag the LobbyManager prefab into your startup scene (or initialize it via script).
  4. Ensure LobbySettings and LobbyVoiceSettings are present in a Resources folder.

2. Server Setup

The backend is a Node.js application located in Assets/Addons/BlinkBox/LobbySystem/Server.

Prerequisites: Node.js v14+ and npm must be installed on your hosting environment.
# Navigate to server directory
cd Assets/Addons/BlinkBox/LobbySystem/Server

# Install dependencies
npm install

# Configure environment
cp .env.example .env

# Start the server
npm start

Environment Variables (.env)

Variable Default Description
PORT 3000 The port the WebSocket server listens on.
NODE_ENV development Set to production for live environments.
ALLOWED_ORIGINS * Comma-separated list of allowed CORS origins.
MAX_PARTY_SIZE 32 Maximum number of players in a single party.

Architecture

The system uses a Client-Server architecture where Unity clients communicate with a Node.js WebSocket server for lobby state, while using Photon PUN for the actual gameplay networking.

Note: The Lobby System is independent of Photon Rooms until the game actually starts. This allows players to form parties in the menu without connecting to a Photon Game Server, saving CCU.

Lobby Manager

The bl_LobbyManager class is the heart of the client-side system. It is a singleton that persists across scenes.

Key Responsibilities

Public Properties

IsConnected Returns true if WebSocket connection is open.
IsInParty Returns true if the local player is currently in a party.
IsPartyLeader Returns true if the local player is the host of the current party.
CurrentPartyCode The 7-digit code used to join the current party.

UI System

Managed by bl_LobbySystemUI.cs. The UI is state-driven and reacts to events from the Lobby Manager.

Key Panels

Player Nameplates

The bl_PlayerNameplate script handles individual player slots. It displays:

Voice Chat

Powered by the ODIN SDK and managed by bl_LobbyVoiceManager.cs.

Features

Configuration

Voice settings are stored in a LobbyVoiceSettings ScriptableObject.

Settings

The system is highly configurable via the bl_LobbySettings ScriptableObject (Right-click > BlinkBox > LobbySystem > Lobby Settings).

Server Settings

UI Settings

Logging

Toggle debug logs for Server messages, Party events, and Voice chat independently.

Node.js Server

The server logic resides in server.js. It uses the ws library for WebSockets and express for the HTTP server.

Features

Socket API

Communication protocol between Unity Client and Node.js Server. All messages are JSON formatted.

Client -> Server Messages

Type Payload Description
identify { clientId, nickname } Registers the connection with a user profile.
create_party { maxSize } Requests creation of a new party.
join_party { code } Attempts to join a party by code.
leave_party {} Leaves the current party.
set_ready { isReady } Updates the local player's ready state.
select_character { characterId } Updates the selected character index.

Server -> Client Messages

Type Payload Description
party_created { id, code } Confirmation of party creation.
player_joined { id, nickname } Notification that a new member joined.
party_state { members, readyStates... } Full sync of party state (sent on join).

Web Monitor

The server includes a built-in web dashboard for monitoring server status.

URL: http://your-server-url/

The public/ folder contains the frontend for this dashboard, visualizing:

C# API Reference

Primary methods available in bl_LobbyManager.

Events

public event Action<string> OnMemberJoined;
public event Action<string> OnMemberLeft;
public event Action<string, bool> OnMemberReadyChanged;
public event Action<string, int> OnMemberCharacterSelected;
public event Action<string> OnPartyLeaderChanged;
public event Action OnPartyLeft;
public event Action OnGameStarted;
public event Action<string> OnPartyCreated;
public event Action OnConnected;
public event Action OnDisconnected;

Methods

// Create a new party
public void CreateParty(int maxSize = 4);

// Join an existing party
public void JoinParty(string code);

// Leave current party
public void LeaveParty();

// Kick a player (Leader only)
public void KickMember(string playerId);

// Set local ready state
public void SetReadyState(bool isReady);

// Select a character
public void SelectCharacter(int characterId);

File Structure

LobbySystem
Art
Core
Docs & Roadmap
Prefabs
Resources
Scripts
bl_LobbyManager.cs
bl_LobbySpawnManager.cs
UI
Voice
Server
server.js
public
package.json