Home Reference Source
public class | source

Signaling

Extends:

* → Signaling

Signaling is an interface with a signaling server with the same APi as foglet-signaling-server {@see https://github.com/RAN3D/foglet-signaling-server}.

It allow for direct connection between peers, or for connection through a signaling server.

Constructor Summary

Public Constructor
public

constructor(source: AbstractNetwork, options: Object)

Constructor

Member Summary

Public Members
public

options: *

Private Members
private

_id: *

private
private

_socket: *

private

_source: *

Method Summary

Public Methods
public

connection(network: AbstractNetwork | null, timeout: number): Promise

Connect the peer to the network.

public

signaling(): void

Enable signaling exchange with a signaling server in order to allow new user to connect with us.

public

unsignaling(): void

Disable signaling exchange and disconnect from the server

Private Methods
private

Manage when a connection error occures

private

_manageDisconnection(reason: Object): void

Manage when a disconnection occures

private

_manageError(error: Object): void

Manage when an error occures

private

_manageTimeout(timeout: Object): void

Manage when a timeout occures

private

Begin a signaling exchange

private

direct(src: Object, dest: Object): function

Enable direct connection between 2 peers

Public Constructors

public constructor(source: AbstractNetwork, options: Object) source

Constructor

Params:

NameTypeAttributeDescription
source AbstractNetwork

The source RPS/network

options Object

Options used to configure the connection to the signaling server

options.address string

URL of the signaling server

options.room string

Name of the room in which the application run

Public Members

public options: * source

Private Members

private _id: * source

private _network: * source

private _socket: * source

private _source: * source

Public Methods

public connection(network: AbstractNetwork | null, timeout: number): Promise source

Connect the peer to the network. If no peer is supplied, rely on the signaling server to connect the peer to the network.

Params:

NameTypeAttributeDescription
network AbstractNetwork | null

(optional) Network to connect with. If not supplied, use the signaling server instead.

timeout number

(optional) Timeout for the interactions with the signaling server

Return:

Promise

A promise fullfilled when the connection is established or failed.

public signaling(): void source

Enable signaling exchange with a signaling server in order to allow new user to connect with us.

Return:

void

public unsignaling(): void source

Disable signaling exchange and disconnect from the server

Return:

void

Private Methods

private _manageConnectionError(error: Object): void source

Manage when a connection error occures

Params:

NameTypeAttributeDescription
error Object

Reason of the connection error returned by socket.io

Return:

void

private _manageDisconnection(reason: Object): void source

Manage when a disconnection occures

Params:

NameTypeAttributeDescription
reason Object

Reason of the disconnection returned by socket.io

Return:

void

private _manageError(error: Object): void source

Manage when an error occures

Params:

NameTypeAttributeDescription
error Object

Error returned by socket.io

Return:

void

private _manageTimeout(timeout: Object): void source

Manage when a timeout occures

Params:

NameTypeAttributeDescription
timeout Object

Timeout error returned by socket.io

Return:

void

private _signalingInit(): function source

Begin a signaling exchange

Return:

function

The function used to handle an offer

private direct(src: Object, dest: Object): function source

Enable direct connection between 2 peers

Params:

NameTypeAttributeDescription
src Object

Source

dest Object

Destination

Return:

function

Function that connect the source to the destination