Skip to main content
Version: 2x

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

NameTypeDescription
fastifyFastifyDevServerFastify instance to attach the WebSocket server to.
configWebSocketHMRServerConfig-

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

NameTypeDescription
socketWebSocketIncoming 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

NameTypeDescription
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

NameType
pathnamestring

Returns

boolean

Inherited from

WebSocketServer.shouldUpgrade

Defined in

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


upgrade

upgrade(request, socket, head): void

Parameters

NameType
requestIncomingMessage
socketSocket
headBuffer

Returns

void

Inherited from

WebSocketServer.upgrade

Defined in

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