Class for creating a WebSocket server for Hot Module Replacement.
↳ WebSocketHMRServer
• 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.
| Name | Type | Description |
|---|---|---|
fastify |
FastifyDevServer |
Fastify instance to attach the WebSocket server to. |
config |
WebSocketHMRServerConfig |
- |
packages/repack/src/server/ws/WebSocketHMRServer.ts:31
• Protected fastify: FastifyDevServer
Fastify instance from which server will receive upgrade connections.
packages/repack/src/server/ws/WebSocketServer.ts:16
• Readonly paths: string[]
packages/repack/src/server/ws/WebSocketServer.ts:18
• Readonly server: Server
An instance of the underlying WebSocket server.
packages/repack/src/server/ws/WebSocketServer.ts:13
▸ onConnection(socket): void
Process new WebSocket connection from HMR client.
| Name | Type | Description |
|---|---|---|
socket |
WebSocket |
Incoming HMR client's WebSocket connection. |
void
packages/repack/src/server/ws/WebSocketHMRServer.ts:123
▸ sendAction(action): void
Send action to all connected HMR clients.
| Name | Type | Description |
|---|---|---|
action |
"building" | "built" | "sync" |
Action to send to the clients. |
void
packages/repack/src/server/ws/WebSocketHMRServer.ts:54
▸ shouldUpgrade(pathname): boolean
| Name | Type |
|---|---|
pathname |
string |
boolean
packages/repack/src/server/ws/WebSocketServer.ts:45
▸ upgrade(request, socket, head): void
| Name | Type |
|---|---|
request |
IncomingMessage |
socket |
Socket |
head |
Buffer |
void