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.
↳ WebSocketDebuggerServer
• 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.
Name | Type | Description |
---|---|---|
fastify |
FastifyDevServer |
Fastify instance to attach the WebSocket server to. |
packages/repack/src/server/ws/WebSocketDebuggerServer.ts:32
• 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
▸ isDebuggerConnected(): boolean
Check if debugger UI is connected to the WebSocketDebuggerServer.
boolean
packages/repack/src/server/ws/WebSocketDebuggerServer.ts:39
▸ onClientConnection(socket
): void
Process new WebSocket connection from React Native app (client) and close any previous connection.
Name | Type | Description |
---|---|---|
socket |
WebSocket |
Incoming client WebSocket connection. |
void
packages/repack/src/server/ws/WebSocketDebuggerServer.ts:110
▸ onConnection(socket
, request
): void
Process new WebSocket connection. The upgrade request should contain role
query param
for determining the type of the connection.
Name | Type | Description |
---|---|---|
socket |
WebSocket |
Incoming WebSocket connection. |
request |
IncomingMessage |
Upgrade request for the connection. |
void
packages/repack/src/server/ws/WebSocketDebuggerServer.ts:64
▸ 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.
Name | Type | Description |
---|---|---|
socket |
WebSocket |
Incoming debugger WebSocket connection. |
void
packages/repack/src/server/ws/WebSocketDebuggerServer.ts:83
▸ send(socket
, message
): void
Send a message to a given WebSocket connection.
Name | Type | Description |
---|---|---|
socket |
undefined | WebSocket |
WebSocket connection to send the message to. |
message |
string |
Message to send. |
void
packages/repack/src/server/ws/WebSocketDebuggerServer.ts:49
▸ 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