Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • WebSocketServer

Index

Properties

clients: Set<WebSocketClient>

Get all connected clients.

off: { (event: "connection", cb: (this: Server<WebSocket>, socket: WebSocket, request: IncomingMessage) => void): Server<WebSocket>; (event: "error", cb: (this: Server<WebSocket>, error: Error) => void): Server<WebSocket>; (event: "headers", cb: (this: Server<WebSocket>, headers: string[], request: IncomingMessage) => void): Server<WebSocket>; (event: "close" | "listening", cb: (this: Server<WebSocket>) => void): Server<WebSocket>; (event: string | symbol, listener: (this: Server<WebSocket>, ...args: any[]) => void): Server<WebSocket> } & ((event: string, listener: Function) => void)

Unregister event listener.

on: { (event: "connection", cb: (this: Server<WebSocket>, socket: WebSocket, request: IncomingMessage) => void): Server<WebSocket>; (event: "error", cb: (this: Server<WebSocket>, error: Error) => void): Server<WebSocket>; (event: "headers", cb: (this: Server<WebSocket>, headers: string[], request: IncomingMessage) => void): Server<WebSocket>; (event: "close" | "listening", cb: (this: Server<WebSocket>) => void): Server<WebSocket>; (event: string | symbol, listener: (this: Server<WebSocket>, ...args: any[]) => void): Server<WebSocket> } & (<T>(event: T, listener: WebSocketCustomListener<InferCustomEventPayload<T>>) => void)

Handle custom event emitted by import.meta.hot.send

Methods

  • close(): Promise<void>
  • Disconnect all clients and terminate the server.

    Returns Promise<void>

  • listen(): void
  • Listen on port and host

    Returns void

  • Broadcast events to all clients

    Parameters

    Returns void

  • Send custom event

    Type parameters

    • T: string

    Parameters

    Returns void