Signaling
Extends:
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 |
_network: * |
|
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 |
_manageConnectionError(error: Object): void 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 |
Enable direct connection between 2 peers |
Public Constructors
public constructor(source: AbstractNetwork, options: Object) source
Constructor
Params:
Name | Type | Attribute | Description |
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:
Name | Type | Attribute | Description |
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 |
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:
Name | Type | Attribute | Description |
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:
Name | Type | Attribute | Description |
reason | Object | Reason of the disconnection returned by socket.io |
Return:
void |
private _manageError(error: Object): void source
Manage when an error occures
Params:
Name | Type | Attribute | Description |
error | Object | Error returned by socket.io |
Return:
void |
private _manageTimeout(timeout: Object): void source
Manage when a timeout occures
Params:
Name | Type | Attribute | Description |
timeout | Object | Timeout error returned by socket.io |
Return:
void |