NetworkManager
Extends:
A NetworkManager manage several distinct Network instances, i.e. a RPS and a set of overlays, and allow peers to choose which network they want to interact with.
Constructor Summary
Public Constructor | ||
public |
constructor(options: Object) Constructor |
Method Summary
Public Methods | ||
public |
Select and get an overlay to use for communication using its name. |
|
public |
registerMiddleware(middleware: Object, priority: Number): void Register a middleware, with an optional priority |
Private Methods | ||
private |
_buildOverlay(overlayConfig: OverlayConfig): void Build and add an overlay |
|
private |
_buildOverlays(overlays: OverlayConfig[]): void Construct all overlays |
|
private |
Construct the RPS by its type and options For the moment(spray-wrtc as default) |
|
private |
_chooseRps(type: string, options: Object): function this method was deprecated. As only Spray is available as RPS, there is only one possible choice...
Get a RPS constructor given its type in string format |
Public Constructors
public constructor(options: Object) source
Constructor
Params:
Name | Type | Attribute | Description |
options | Object | Options used to build the networks |
|
options.rps | Object | Options used to configure the Random Peer Sampling (RPS) network |
|
options.rps.type | string | The type of RPS ( |
|
options.rps.options | Object | Options by the type of RPS choosed |
|
options.rps.options.protocol | string | Name of the protocol run by the application |
|
options.rps.options.webrtc | Object | WebRTC dedicated options (see WebRTC docs for more details) |
|
options.rps.options.timeout | number | RPS timeout before definitively close a WebRTC connection |
|
options.rps.options.delta | number | RPS shuffle interval |
|
options.rps.options.signaling | Object | Options used to configure the interactions with the signaling server |
|
options.rps.options.signaling.address | string | URL of the signaling server |
|
options.rps.options.signaling.room | string | Name of the room in which the application run |
|
options.overlay | Object | Options used to configure custom overlay in addition of the RPS |
|
options.overlay.options | Object | Options propagated to all overlays, same as the options field used to configure the RPS. |
|
options.overlay.overlays | OverlayConfig[] | Set of config objects used to build the overlays |
Public Methods
public overlay(name: string): Network source
Select and get an overlay to use for communication using its name. If no name is specified, the base RPS will be returned.
Params:
Name | Type | Attribute | Description |
name | string |
|
(optional) Name of the overlay to get. Default to the RPS. |
public registerMiddleware(middleware: Object, priority: Number): void source
Register a middleware, with an optional priority
Return:
void |
Private Methods
private _buildOverlay(overlayConfig: OverlayConfig): void source
Build and add an overlay
Params:
Name | Type | Attribute | Description |
overlayConfig | OverlayConfig | Overlay configuration object |
Return:
void |
Throw:
Overlay configuration object must be a valid |
|
An overlay with the same name has laready been registered |
private _buildOverlays(overlays: OverlayConfig[]): void source
Construct all overlays
Params:
Name | Type | Attribute | Description |
overlays | OverlayConfig[] | Set of overlay config objetcs |
Return:
void |
private _buildRPS(type: string, options: Object): Network source
Construct the RPS by its type and options For the moment(spray-wrtc as default)
Params:
Name | Type | Attribute | Description |
type | string | Type of the RPS (spray-wrtc/custom/...) |
|
options | Object | Options of the RPS |
|
options.protocol | string | Name of the protocol run by the RPS |
|
options.signaling | Object | Options used to configure the interactions with the signaling server |
|
options.signaling.address | string | URL of the signaling server |
|
options.signaling.room | string | Name of the room in which the application run |