Class: WebSocketEventsServer

Class for creating a WebSocket server to process events and reports.

Based on: https://github.com/react-native-community/cli/blob/v4.14.0/packages/cli-server-api/src/websocket/eventsSocketServer.ts

Hierarchy

Table of contents

Constructors

Properties

Methods

Constructors

constructor

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.

Parameters

Name Type Description
fastify FastifyDevServer Fastify instance to attach the WebSocket server to.
config WebSocketEventsServerConfig Configuration object.

Overrides

WebSocketServer.constructor

Defined in

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

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


PROTOCOL_VERSION

Static Readonly PROTOCOL_VERSION: 2

Defined in

packages/repack/src/server/ws/WebSocketEventsServer.ts:42

Methods

broadcastEvent

broadcastEvent(event): void

Broadcast event to all connected clients.

Parameters

Name Type Description
event EventMessage Event message to broadcast.

Returns

void

Defined in

packages/repack/src/server/ws/WebSocketEventsServer.ts:138


onConnection

onConnection(socket): void

Process new client's WebSocket connection.

Parameters

Name Type Description
socket WebSocket Incoming WebSocket connection.

Returns

void

Overrides

WebSocketServer.onConnection

Defined in

packages/repack/src/server/ws/WebSocketEventsServer.ts:167


parseMessage

parseMessage(data): undefined | Command

Parse received command message from connected client.

Parameters

Name Type Description
data string Stringified command message to parse.

Returns

undefined | Command

Parsed command or undefined if parsing failed.

Defined in

packages/repack/src/server/ws/WebSocketEventsServer.ts:71


serializeMessage

serializeMessage(message): undefined | string

Stringify message into a format that can be transported as a string.

Parameters

Name Type Description
message EventMessage Message to serialize.

Returns

undefined | string

String representation of a message or undefined if serialization failed.

Defined in

packages/repack/src/server/ws/WebSocketEventsServer.ts:97


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