Master-owned WebSocket upgrade routing, rooms, and per-app handlers.
Engine-internal — not for sandboxed app require.
Public apps use require('websockets') which talks to this hub via getContext().
- Description:
- Master-owned WebSocket upgrade routing, rooms, and per-app handlers.
Engine-internal — not for sandboxed app require.
Public apps use require('websockets') which talks to this hub via getContext().
Members
(static) _sockets
- Description:
test helpers
(inner, constant) DEFAULTS :object
Type:
(inner, constant) STATE_KEY
- Description:
- Process-wide singleton state so sandbox require() and engine require()
always share the same connection/room maps (avoids duplicate module instances).
Process-wide singleton state so sandbox require() and engine require()
always share the same connection/room maps (avoids duplicate module instances).
Methods
(inner) assertRoomTenant(room, tenantId)
- Description:
- Ensure room is under tenant prefix (for multi-tenant apps).
Parameters:
| Name |
Type |
Description |
room |
string
|
|
tenantId |
string
|
number
|
|
(inner) attachServer(server)
- Description:
- Attach upgrade listener to an http.Server / https.Server.
Parameters:
| Name |
Type |
Description |
server |
object
|
Node http.Server or https.Server |
(inner) createFacade(entry)
Parameters:
| Name |
Type |
Description |
entry |
object
|
|
(inner) fullPathFor(appName, relativePath)
- Description:
- Full public path for an app binding: /{appName}{relativePath}
Parameters:
| Name |
Type |
Description |
appName |
string
|
|
relativePath |
string
|
|
(inner) getActiveAppName() → {string|null}
Returns:
app name for the active WS handler/message dispatch
-
Type
-
string
|
null
(async, inner) handleUpgrade(req, socket, head)
Parameters:
| Name |
Type |
Description |
req |
object
|
http.IncomingMessage |
socket |
object
|
net.Socket / stream.Duplex from upgrade |
head |
Buffer
|
|
(inner) initServer(cfg, logger, globalConfigopt)
- Description:
- Initialize WebSocket hub (sync). Redis fan-out starts in the background when configured.
Parameters:
| Name |
Type |
Attributes |
Description |
cfg |
object
|
null
|
undefined
|
|
|
logger |
object
|
|
|
globalConfig |
object
|
<optional>
|
|
(inner) onConnection(ws, req)
Parameters:
| Name |
Type |
Description |
ws |
object
|
ws.WebSocket |
req |
object
|
http.IncomingMessage |
(inner) parseUpgradeUrl(url) → {Object|null}
- Description:
- Parse upgrade URL into app name + remainder path.
Parameters:
| Name |
Type |
Description |
url |
string
|
|
Returns:
-
Type
-
Object
|
null
(async, inner) registerApp(app, globalConfigopt)
Parameters:
| Name |
Type |
Attributes |
Description |
app |
object
|
|
|
globalConfig |
object
|
<optional>
|
|
(inner) sendToApp(appName, data, optsopt) → {number}
- Description:
- Broadcast to all connections of an app (local + optional multi-node fan-out).
Parameters:
| Name |
Type |
Attributes |
Description |
appName |
string
|
|
|
data |
*
|
|
|
opts |
object
|
<optional>
|
Properties
| Name |
Type |
Attributes |
Description |
fromFanout |
boolean
|
<optional>
|
|
|
Returns:
local recipients
-
Type
-
number
(inner) sendToRoom(appName, room, data, optsopt) → {number}
Parameters:
| Name |
Type |
Attributes |
Description |
appName |
string
|
|
|
room |
string
|
|
|
data |
*
|
|
|
opts |
object
|
<optional>
|
Properties
| Name |
Type |
Attributes |
Description |
excludeId |
string
|
<optional>
|
|
fromFanout |
boolean
|
<optional>
|
skip re-publish when applying remote message |
|
Returns:
local recipients (other nodes not counted)
-
Type
-
number
(inner) setAppsRegistry(apps)
Parameters:
| Name |
Type |
Description |
apps |
object
|
null
|
|
(inner) tenantRoom(tenantId, name)
- Description:
- Tenant room helper: t:{tenantId}:{name}
Parameters:
| Name |
Type |
Description |
tenantId |
string
|
number
|
|
name |
string
|
|
(inner) unregisterApp(appName, optsopt)
Parameters:
| Name |
Type |
Attributes |
Description |
appName |
string
|
|
|
opts |
object
|
<optional>
|
|