method WebSocketService.prototype.peek
Since 0.4.0
WebSocketService.prototype.peek(name: string): WebSocketRoom | undefined

Returns the named room if one already exists, without creating it.

The non-allocating counterpart to WebSocketService.room. A presence endpoint reading size for a request-supplied name must use this: room() registers one room per distinct name polled, and a room nobody joined is reclaimed only on the next disconnection.

Parameters

name: string

Room name

Return Type

WebSocketRoom | undefined

The room, or undefined when no room of that name exists

Usage

import { WebSocketService } from "websocket-plugin/src/index.ts";