Class: WebSocketHMRServer

Class for creating a WebSocket server for Hot Module Replacement.

Hierarchy

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new WebSocketHMRServer(fastify, config)

Create new instance of WebSocketHMRServer and attach it to the given Fastify instance. Any logging information, will be passed through standard fastify.log API.

Parameters

Name Type Description
fastify FastifyDevServer Fastify instance to attach the WebSocket server to.
config WebSocketHMRServerConfig -

Overrides

WebSocketServer.constructor

Defined in

packages/repack/src/server/ws/WebSocketHMRServer.ts:31

Properties

fastify

Protected fastify: FastifyDevServer

Fastify instance from which server will receive upgrade connections.

Inherited from

WebSocketServer.fastify

Defined in

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


paths

Readonly paths: string[]

Inherited from

WebSocketServer.paths

Defined in

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


server

Readonly server: Server

An instance of the underlying WebSocket server.

Inherited from

WebSocketServer.server

Defined in

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

Methods

onConnection

onConnection(socket): void

Process new WebSocket connection from HMR client.

Parameters

Name Type Description
socket WebSocket Incoming HMR client's WebSocket connection.

Returns

void

Overrides

WebSocketServer.onConnection

Defined in

packages/repack/src/server/ws/WebSocketHMRServer.ts:123


sendAction

sendAction(action): void

Send action to all connected HMR clients.

Parameters

Name Type Description
action "building" | "built" | "sync" Action to send to the clients.

Returns

void

Defined in

packages/repack/src/server/ws/WebSocketHMRServer.ts:54


shouldUpgrade

shouldUpgrade(pathname): boolean

Parameters

Name Type
pathname string

Returns

boolean

Inherited from

WebSocketServer.shouldUpgrade

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

Inherited from

WebSocketServer.upgrade

Defined in

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