Class: WebSocketServer

Abstract class for providing common logic (eg routing) for all WebSocket servers.

Hierarchy

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new WebSocketServer(fastify, path, wssOptions?)

Create a new instance of the WebSocketServer. Any logging information, will be passed through standard fastify.log API.

Parameters

Name Type Description
fastify FastifyDevServer Fastify instance to which the WebSocket will be attached to.
path string | string[] Path on which this WebSocketServer will be accepting connections.
wssOptions Omit<ServerOptions, "host" | "port" | "noServer" | "server" | "path"> WebSocket Server options.

Defined in

packages/repack/src/server/ws/WebSocketServer.ts:28

Properties

fastify

Protected fastify: FastifyDevServer

Fastify instance from which server will receive upgrade connections.

Defined in

packages/repack/src/server/ws/WebSocketServer.ts:16


paths

Readonly paths: string[]

Defined in

packages/repack/src/server/ws/WebSocketServer.ts:18


server

Readonly server: Server

An instance of the underlying WebSocket server.

Defined in

packages/repack/src/server/ws/WebSocketServer.ts:13

Methods

onConnection

Abstract onConnection(socket, request): void

Process incoming WebSocket connection.

Parameters

Name Type Description
socket WebSocket Incoming WebSocket connection.
request IncomingMessage Upgrade request for the connection.

Returns

void

Defined in

packages/repack/src/server/ws/WebSocketServer.ts:61


shouldUpgrade

shouldUpgrade(pathname): boolean

Parameters

Name Type
pathname string

Returns

boolean

Defined in

packages/repack/src/server/ws/WebSocketServer.ts:45


upgrade

upgrade(request, socket, head): void

Parameters

Name Type
request IncomingMessage
socket Socket
head Buffer

Returns

void

Defined in

packages/repack/src/server/ws/WebSocketServer.ts:49