Abstract class for providing common logic (eg routing) for all WebSocket servers.
WebSocketServer
• new WebSocketServer(fastify
, path
, wssOptions?
)
Create a new instance of the WebSocketServer.
Any logging information, will be passed through standard fastify.log
API.
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. |
packages/repack/src/server/ws/WebSocketServer.ts:28
• 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
▸ Abstract
onConnection(socket
, request
): void
Process incoming WebSocket connection.
Name | Type | Description |
---|---|---|
socket |
WebSocket |
Incoming WebSocket connection. |
request |
IncomingMessage |
Upgrade request for the connection. |
void
packages/repack/src/server/ws/WebSocketServer.ts:61
▸ 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