Class for creating a WebSocket server to process events and reports.
↳ WebSocketEventsServer
• new WebSocketEventsServer(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 |
WebSocketEventsServerConfig |
Configuration object. |
packages/repack/src/server/ws/WebSocketEventsServer.ts:54
• 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
▪ Static
Readonly
PROTOCOL_VERSION: 2
packages/repack/src/server/ws/WebSocketEventsServer.ts:42
▸ broadcastEvent(event
): void
Broadcast event to all connected clients.
Name | Type | Description |
---|---|---|
event |
EventMessage |
Event message to broadcast. |
void
packages/repack/src/server/ws/WebSocketEventsServer.ts:138
▸ onConnection(socket
): void
Process new client's WebSocket connection.
Name | Type | Description |
---|---|---|
socket |
WebSocket |
Incoming WebSocket connection. |
void
packages/repack/src/server/ws/WebSocketEventsServer.ts:167
▸ parseMessage(data
): undefined
| Command
Parse received command message from connected client.
Name | Type | Description |
---|---|---|
data |
string |
Stringified command message to parse. |
undefined
| Command
Parsed command or undefined
if parsing failed.
packages/repack/src/server/ws/WebSocketEventsServer.ts:71
▸ serializeMessage(message
): undefined
| string
Stringify message
into a format that can be transported as a string
.
Name | Type | Description |
---|---|---|
message |
EventMessage |
Message to serialize. |
undefined
| string
String representation of a message
or undefined
if serialization failed.
packages/repack/src/server/ws/WebSocketEventsServer.ts:97
▸ 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