Members
(constant) rooms :Object.<string, Array.<Room>>
- Source:
Type:
-
Object.<string, Array.<Room>>
(constant) server
- Description:
- Sets up the WebSocket server and handles incoming connections and messages.
- Source:
Sets up the WebSocket server and handles incoming connections and messages.
Methods
broadcastToRoom(roomId, message, excludeUserId)
- Description:
- Broadcasts a message to all participants in a room, optionally excluding a specific user.
- Source:
Parameters:
Name |
Type |
Default |
Description |
roomId |
string
|
|
The ID of the room. |
message |
Object
|
|
The message object to broadcast. |
excludeUserId |
string
|
null
|
null
|
The user ID to exclude from broadcasting. |
getRoomIdByUserId(userId) → {string|null}
- Description:
- Utility function to get roomId by userId.
Assumes each user is in only one room.
- Source:
Parameters:
Name |
Type |
Description |
userId |
string
|
The user's unique identifier. |
Returns:
- The room ID if found, otherwise null.
-
Type
-
string
|
null
getWebSocketByUserId(userId) → {WebSocket|null}
- Description:
- Utility function to get WebSocket connection by userId.
- Source:
Parameters:
Name |
Type |
Description |
userId |
string
|
The user's unique identifier. |
Returns:
- The WebSocket connection if found, otherwise null.
-
Type
-
WebSocket
|
null
handleDataMessage(ws, payload)
- Description:
- Handles incoming data messages from clients and broadcasts them.
- Source:
Parameters:
Name |
Type |
Description |
ws |
WebSocket
|
The WebSocket connection from the sender. |
payload |
Object
|
The payload containing from, to, and message. |
handleWSDisconnect(ws)
- Description:
- Handles WebSocket disconnections by removing the user from wsConnections.
- Source:
Parameters:
Name |
Type |
Description |
ws |
WebSocket
|
The WebSocket connection that was closed. |
handleWSJoin(ws, payload)
- Description:
- Handles a WebSocket join request by authenticating and adding the user to wsConnections.
- Source:
Parameters:
Name |
Type |
Description |
ws |
WebSocket
|
The WebSocket connection. |
payload |
Object
|
The payload containing roomId, userId, and token.
Properties
Name |
Type |
Description |
roomId |
string
|
The ID of the room to join. |
userId |
string
|
The user's unique identifier. |
token |
string
|
The JWT token for authentication. |
|
Type Definitions
AudioQualitySettings
- Source:
Properties:
Name |
Type |
Description |
maxBitrate |
number
|
Maximum audio bitrate in bps |
sampleRate |
number
|
Audio sample rate in Hz |
channelCount |
number
|
Number of audio channels (1=mono, 2=stereo) |
Type:
ConnectionStats
- Source:
Properties:
Name |
Type |
Description |
outbound |
Object
|
Outbound (sending) statistics
Properties
Name |
Type |
Description |
bitrate |
number
|
Current outbound bitrate in bits/s |
packetLoss |
number
|
Percentage of packets lost |
qualityLimitation |
string
|
Reason for quality limitations (if any) |
|
inbound |
Object
|
Inbound (receiving) statistics per track
Properties
Name |
Type |
Description |
bitrate |
number
|
Current inbound bitrate in bits/s |
packetLoss |
number
|
Percentage of packets lost |
jitter |
number
|
Current jitter in seconds |
|
connection |
Object
|
Overall connection statistics
Properties
Name |
Type |
Description |
roundTripTime |
number
|
Current round trip time in seconds |
state |
string
|
Current connection state |
|
Type:
QualityPreset
- Source:
Properties:
Type:
Room
- Description:
- In-memory storage for rooms and participants.
- Source:
Properties:
Name |
Type |
Description |
userId |
string
|
Unique identifier for the user. |
sessionId |
string
|
Unique identifier for the session. |
createdAt |
number
|
Timestamp when the participant was added. |
offers |
Array
|
Array of offer objects. |
In-memory storage for rooms and participants.
Type:
StreamStats
- Source:
Properties:
Name |
Type |
Description |
sessionId |
string
|
Session ID of the stream |
packetLoss |
number
|
Packet loss percentage |
qualityLimitation |
string
|
Quality limitation reason |
bitrate |
number
|
Current bitrate |
Type:
VideoQualitySettings
- Source:
Properties:
Name |
Type |
Description |
width |
Object
|
Video width settings
Properties
Name |
Type |
Description |
ideal |
number
|
Ideal video width in pixels |
|
height |
Object
|
Video height settings
Properties
Name |
Type |
Description |
ideal |
number
|
Ideal video height in pixels |
|
frameRate |
Object
|
Frame rate settings
Properties
Name |
Type |
Description |
ideal |
number
|
Ideal frame rate in fps |
|
maxBitrate |
number
|
Maximum video bitrate in bps |
Type: