Skip to main content
Version: 2x

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

NameTypeDescription
fastifyFastifyDevServerFastify instance to attach the WebSocket server to.
configWebSocketEventsServerConfigConfiguration 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

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

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

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

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

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