Class: WebSocketDebuggerServer

Class for creating a WebSocket server and providing a bridge between debugger UI (Remote JS debugger) and the running React Native application.

React Native application (aka client) will send and receive messages from the debugger UI which runs inside a browser.

Hierarchy

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new WebSocketDebuggerServer(fastify)

Create new instance of WebSocketDebuggerServer 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.

Overrides

WebSocketServer.constructor

Defined in

packages/repack/src/server/ws/WebSocketDebuggerServer.ts:32

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

Methods

isDebuggerConnected

isDebuggerConnected(): boolean

Check if debugger UI is connected to the WebSocketDebuggerServer.

Returns

boolean

Defined in

packages/repack/src/server/ws/WebSocketDebuggerServer.ts:39


onClientConnection

onClientConnection(socket): void

Process new WebSocket connection from React Native app (client) and close any previous connection.

Parameters

Name Type Description
socket WebSocket Incoming client WebSocket connection.

Returns

void

Defined in

packages/repack/src/server/ws/WebSocketDebuggerServer.ts:110


onConnection

onConnection(socket, request): void

Process new WebSocket connection. The upgrade request should contain role query param for determining the type of the connection.

Parameters

Name Type Description
socket WebSocket Incoming WebSocket connection.
request IncomingMessage Upgrade request for the connection.

Returns

void

Overrides

WebSocketServer.onConnection

Defined in

packages/repack/src/server/ws/WebSocketDebuggerServer.ts:64


onDebuggerConnection

onDebuggerConnection(socket): void

Process new WebSocket connection from Debugger UI (Remote JS Debugger). If there's already open connection, the new one gets closed automatically.

Parameters

Name Type Description
socket WebSocket Incoming debugger WebSocket connection.

Returns

void

Defined in

packages/repack/src/server/ws/WebSocketDebuggerServer.ts:83


send

send(socket, message): void

Send a message to a given WebSocket connection.

Parameters

Name Type Description
socket undefined | WebSocket WebSocket connection to send the message to.
message string Message to send.

Returns

void

Defined in

packages/repack/src/server/ws/WebSocketDebuggerServer.ts:49


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