lib/signaling
Signaling client for the WebRTC transport.
Speaks the line protocol of the server's signaling WebSocket. HELLO <peer type> <json> registers the client, the JSON carrying its type, slot,
strict-viewer flag, secure-mode token, display id and display position;
SESSION server asks for the server peer and is answered with
SESSION_OK <peer id>; from then on the SDP and the ICE candidates travel
as <peer id> {"sdp": ...} and <peer id> {"ice": ...} lines, and
ERROR ... lines report server-side failures. The server always offers
and the client answers.
A failed or dropped connection retries after three seconds; the fourth
consecutive failure hands over to onfatalretry (or reloads the page) so
the browser re-runs HTTP authentication.
Classes
WebRTCSignaling
Defined in: lib/signaling.js:52
Connection to the signaling server, delivering SDP and ICE to callbacks.
Callbacks are assigned as properties: onstatus, ondebug and onerror
receive messages, onsdp an RTCSessionDescription, onice an
RTCIceCandidate, ondisconnect whether the app should reconnect,
onshowalert a reason to show the user, and onfatalretry replaces the
page reload after repeated failures.
Constructors
Constructor
new WebRTCSignaling(
server,
client_type,
client_slot,
client_strict_viewer,
client_token,
display_id,
display_position
): WebRTCSignaling;Defined in: lib/signaling.js:67
Parameters
| Parameter | Type | Description |
|---|---|---|
server | URL | Signaling WebSocket URL. |
client_type | string | 'controller' or 'viewer'. |
client_slot | number | Client slot the server assigns per display. |
client_strict_viewer | boolean | Whether a viewer may never gain control. |
client_token | string | Secure-mode session token; the server matches it against the active mouse+keyboard token to grant a viewer read-write collaboration. |
display_id | string | Display this client drives, 'primary' by default; the server scopes controller and slot uniqueness per display so a secondary display never evicts the primary. |
display_position | string | Where a secondary display sits relative to the primary in the extended desktop, 'right' by default. |
Returns
Properties
peer_id
peer_id: number;Defined in: lib/signaling.js:72
Local peer id, set by the WebRTC client before connect.
onstatus
onstatus: (arg0) => void;Defined in: lib/signaling.js:78
Parameters
| Parameter | Type |
|---|---|
arg0 | string |
Returns
void
onfatalretry
onfatalretry: () => void;Defined in: lib/signaling.js:85
Called instead of the page reload after repeated connect failures, so the app may inspect the endpoint before reloading.
Returns
void
onerror
onerror: (arg0) => void;Defined in: lib/signaling.js:88
Parameters
| Parameter | Type |
|---|---|
arg0 | string |
Returns
void
ondebug
ondebug: (arg0) => void;Defined in: lib/signaling.js:91
Parameters
| Parameter | Type |
|---|---|
arg0 | string |
Returns
void
onice
onice: (arg0) => void;Defined in: lib/signaling.js:94
Parameters
| Parameter | Type |
|---|---|
arg0 | RTCIceCandidate |
Returns
void
onsdp
onsdp: (arg0) => void;Defined in: lib/signaling.js:97
Parameters
| Parameter | Type |
|---|---|
arg0 | RTCSessionDescription |
Returns
void
ondisconnect
ondisconnect: (arg0) => void;Defined in: lib/signaling.js:100
Called with whether the app should reconnect.
Parameters
| Parameter | Type |
|---|---|
arg0 | boolean |
Returns
void
state
state: string;Defined in: lib/signaling.js:103
'disconnected', 'connecting' or 'connected'.
retry_count
retry_count: number;Defined in: lib/signaling.js:106
currRes
currRes: number[];Defined in: lib/signaling.js:121
peer_type
peer_type: string;Defined in: lib/signaling.js:124
client_type
client_type: string;Defined in: lib/signaling.js:127
'viewer' or 'controller'.
server_peer_id
server_peer_id: string;Defined in: lib/signaling.js:130
client_slot
client_slot: number;Defined in: lib/signaling.js:133
client_strict_viewer
client_strict_viewer: boolean;Defined in: lib/signaling.js:136
client_token
client_token: string;Defined in: lib/signaling.js:139
display_id
display_id: string;Defined in: lib/signaling.js:142
display_position
display_position: string;Defined in: lib/signaling.js:145
onshowalert
onshowalert: (arg0) => void;Defined in: lib/signaling.js:148
Parameters
| Parameter | Type |
|---|---|
arg0 | string |
Returns
void
Methods
connect()
connect(): void;Defined in: lib/signaling.js:342
Opens the signaling socket; registration, the session request and the SDP and ICE exchange follow from the socket events.
Returns
void
disconnect()
disconnect(): void;Defined in: lib/signaling.js:355
Closes the socket; the close is reported as ondisconnect(false), not as a drop.
Returns
void
sendICE()
sendICE(ice): void;Defined in: lib/signaling.js:364
Sends a local ICE candidate to the server peer.
Parameters
| Parameter | Type | Description |
|---|---|---|
ice | RTCIceCandidate | - |
Returns
void
sendSDP()
sendSDP(sdp): void;Defined in: lib/signaling.js:373
Sends the local description (the answer) to the server peer.
Parameters
| Parameter | Type | Description |
|---|---|---|
sdp | RTCSessionDescription | - |
Returns
void