Selkies
Developer ReferenceWeb client coreLib

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
ParameterTypeDescription
serverURLSignaling WebSocket URL.
client_typestring'controller' or 'viewer'.
client_slotnumberClient slot the server assigns per display.
client_strict_viewerbooleanWhether a viewer may never gain control.
client_tokenstringSecure-mode session token; the server matches it against the active mouse+keyboard token to grant a viewer read-write collaboration.
display_idstringDisplay this client drives, 'primary' by default; the server scopes controller and slot uniqueness per display so a secondary display never evicts the primary.
display_positionstringWhere a secondary display sits relative to the primary in the extended desktop, 'right' by default.
Returns

WebRTCSignaling

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
ParameterType
arg0string
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
ParameterType
arg0string
Returns

void

ondebug
ondebug: (arg0) => void;

Defined in: lib/signaling.js:91

Parameters
ParameterType
arg0string
Returns

void

onice
onice: (arg0) => void;

Defined in: lib/signaling.js:94

Parameters
ParameterType
arg0RTCIceCandidate
Returns

void

onsdp
onsdp: (arg0) => void;

Defined in: lib/signaling.js:97

Parameters
ParameterType
arg0RTCSessionDescription
Returns

void

ondisconnect
ondisconnect: (arg0) => void;

Defined in: lib/signaling.js:100

Called with whether the app should reconnect.

Parameters
ParameterType
arg0boolean
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
ParameterType
arg0string
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
ParameterTypeDescription
iceRTCIceCandidate-
Returns

void

sendSDP()
sendSDP(sdp): void;

Defined in: lib/signaling.js:373

Sends the local description (the answer) to the server peer.

Parameters
ParameterTypeDescription
sdpRTCSessionDescription-
Returns

void

On this page

Edit on GitHub