Skip to main content
Version: 2x

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

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

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

NameTypeDescription
socketWebSocketIncoming WebSocket connection.
requestIncomingMessageUpgrade 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

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

NameTypeDescription
socketundefined | WebSocketWebSocket connection to send the message to.
messagestringMessage to send.

Returns

void

Defined in

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


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