Constructor
new ConnectivityManager(cypherpokerRef)
Creates an instance of ConnectivityManager.
Parameters:
Name | Type | Description |
---|---|---|
cypherpokerRef |
CypherPoker | The CypherPoker instance for which this class is controlling connectivity. |
- Source:
- See:
Extends
Members
api
Properties:
Name | Type | Default | Description |
---|---|---|---|
api |
Object | null | Reference to a multi-network routing interface over which RPC API functions are invoked. For example, APIRouter. |
- Source:
(readonly) apiConnected
Properties:
Name | Type | Default | Description |
---|---|---|---|
apiConnected |
Boolean | false | True if the instance is connected to the API services provider and ready to accept requests. |
- Source:
(readonly) cypherpoker
Properties:
Name | Type | Description |
---|---|---|
cypherpoker |
CypherPoker | The main CypherPoker instance for which this class is managing connectivity, as set at instantiation. |
- Source:
p2p
Properties:
Name | Type | Default | Description |
---|---|---|---|
p2p |
Object | null | Reference to a peer-to-peer multi-network routing interface supporting a dynamic private ID, direct send (single or multi), and broadcast functionality. For example, P2PRouter |
- Source:
(readonly) p2pConnected
Properties:
Name | Type | Default | Description |
---|---|---|---|
p2pConnected |
Boolean | false | True if the instance is connected to the peer-to-peer network and ready to accept requests. |
- Source:
selectors
Properties:
Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
selectors |
Object | Name/value pairs for UI elements and their
associated CSS-style DOM selectors within the connectivity management template connectivityManage.html
Properties
|
- Source:
Methods
addEventListener(type, listener, contextopt)
Registers a new event listener with the extending class instance.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
type |
String | The event type to register. | ||
listener |
function | The listening function to invoke on the event. | ||
context |
Object |
<optional> |
null | Unlike the traditional addEventListener parameter, this is
the context or scope in which to invoke the listening function (since we can't use capture phases).
If null, the listener is invoked in the context of the EventDispatcher or extending instance. |
- Inherited From:
- Source:
adjustURL(connectionURL) → {String}
Adjusts a URL that contains additional information that would be considered invalid
(such as a "tunnel@" protocol prefix, for example).
Parameters:
Name | Type | Description |
---|---|---|
connectionURL |
String | The URL to adjust. |
- Source:
Returns:
The adjusted URL.
- Type
- String
canShareConnections(connectObj1, connectObj2) → {Boolean}
Determines if two connection and transport settings objects are the same
and can therefore be shared.
Parameters:
Name | Type | Description |
---|---|---|
connectObj1 |
Object | The first connection info object to compare. |
connectObj2 |
Object | The second connection info object to compare. |
- Source:
Returns:
True if both the URLs and transports specified
by the settings are the same, false otherwise.
- Type
- Boolean
(async) confirmConnectAPI(gameActiveopt, joinActiveopt)
Trigerred after onConnectAPIClick either
directly or as a result of a confirmation by the plyer. A new API connection is
established by gathering the url, create script, and generating a connection type
via getTransportType, creating
a new
connectInfo
object, and using it to replace the current
cypherpoker.settings.api.connectInfo
setting.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
gameActive |
Boolean |
<optional> |
false | If true, any existing games are destroyed prior to establishing the new connection. |
joinActive |
Boolean |
<optional> |
false | If true, any existing table advertisement or join requests are cancelled prior to establishing the new connection. |
- Source:
(async) confirmConnectP2P(gameActiveopt, joinActiveopt)
Trigerred after onConnectP2PClick either
directly or as a result of a confirmation by the plyer. A new P2P connection is
established by gathering the url, create script, and generating a connection type
via getTransportType, creating
a new
connectInfo
object, and using it to replace the current
cypherpoker.settings.p2p.connectInfo
setting.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
gameActive |
Boolean |
<optional> |
false | If true, any existing games are destroyed prior to establishing the new connection. |
joinActive |
Boolean |
<optional> |
false | If true, any existing table advertisement or join requests are cancelled prior to establishing the new connection. |
- Source:
(async) confirmConnectSDB(gameActiveopt, joinActiveopt)
Trigerred after onConnectUsingSDBClick either
directly or as a result of a confirmation by the plyer. New connection(s) is/are
determined from the SDB, closing any current connections, and establishing new ones.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
gameActive |
Boolean |
<optional> |
false | If true, any existing games are destroyed prior to establishing the new connection. |
joinActive |
Boolean |
<optional> |
false | If true, any existing table advertisement or join requests are cancelled prior to establishing the new connection. |
- Source:
(async) connectAPI(sharedConnectionopt) → {Promise}
Creates a new API connection specified in the
api
definition
of the settings object, and assigns it to the
api reference.
If a connection aready exists, it's destroyed and removed first.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
sharedConnection |
Object |
<optional> |
null | An optional shared / multiplexed connection already established (for example, the connection used for the p2p); |
- Source:
Returns:
The returned promise will resolve with the true if
the connection was successfully established and false if the connection
attempt failed.
- Type
- Promise
(async) connectFromSDB(sdb, entityTypeopt, statusCBopt) → {Promise}
Establishes connection(s) using information from a Services Descriptor Bundle.
This may result in new api and/or p2p
instances being created and connected. Related
connectInfo
objects in the
settings object are updated accordingly.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
sdb |
String | Array | Either Base85 / Ascii85 (including -s variant), or Base64 encoded string, or
a native JavaScript array containing SDB entities. |
||
entityType |
String |
<optional> |
"*" | The type of SDB entity to connect to, if
contained in the sdb . Valid types are "api" or "p2p". If "*"
is supplied, all included entities are connected. |
statusCB |
function |
<optional> |
null | Optional callback function that tracks
the status of the connection(s) progress. This function will receive
a single object parameter with properties entity (the entity
for which the status is being reported), status (either "connecting",
"connected", or "failed"), and url (the assembled connection URL). |
- Source:
Returns:
The returned promise will resolve with the true if
all the specified connections connected successfuly, or false if one
or more failed.
- Type
- Promise
(async) connectP2P(sharedConnectionopt) → {Promise}
Creates a new peer-to-peer rendezvous / signalling connection specified
in the
p2p
definition of the settings
object, and assigns it to the p2p reference.
If a connection aready exists, it's destroyed and removed first.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
sharedConnection |
Object |
<optional> |
null | An optional shared / multiplexed connection already established (for example, the connection used for the api); |
- Source:
Returns:
The returned promise will resolve with the true if
the connection was successfully established and false if the connection
attempt failed.
- Type
- Promise
getConnectionName(connectionInfo) → {String}
Returns a descriptive, human-readable name for a connection type.
Parameters:
Name | Type | Description |
---|---|---|
connectionInfo |
String | Object | Either a connection type to evaluate directly
or an object containing a type property to evaluate. |
- Source:
Returns:
A descriptive name for the connection type. A blank string is returned
for any unrecignized type.
- Type
- String
getConnectionParameters(connectionURL) → {URLSearchParams}
Returns the parameters included with a supplied URL.
Parameters:
Name | Type | Description |
---|---|---|
connectionURL |
String | The URL from which to determine the parameters. |
- Source:
Returns:
The parameters included with the URL
- Type
- URLSearchParams
getConnectionSecurity(connectionInfo, addSpaceopt) → {String}
Returns a human-readable security descriptor (e.g. "Secure") for a connection type.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
connectionInfo |
String | Object | Either a connection url to evaluate directly
or an object containing a url property to evaluate. |
||
addSpace |
Boolean |
<optional> |
true | If true, an extra space is added to the end of the descriptor unless it's an empty string. |
- Source:
Returns:
The security descriptor, either "Secure" or an empty string for
insecure.
- Type
- String
getListeners(type) → {Array}
Returns all registered listeners for a specific event type.
Parameters:
Name | Type | Description |
---|---|---|
type |
String | The event type to return registered listeners for. |
- Inherited From:
- Source:
Returns:
A list of registered event listener objects for the specific event.
Each object contains a
listener
function reference and an
execution context
reference.
- Type
- Array
getSavedConnections(connectionTypeopt) → {Array|Object}
Loads any saved connections stored by the user.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
connectionType |
String |
<optional> |
null | The type of connection information
to retrieve, either api or p2p |
- Source:
Returns:
Indexed array of objects containing saved connection
information, or an object containing all saved connections contained in
named indexed arrays.
- Type
- Array | Object
getTransportType(connectionURL) → {String}
Returns the transport type based on a supplied URL.
Parameters:
Name | Type | Description |
---|---|---|
connectionURL |
String | The URL from which to determine the transport type. |
- Source:
Returns:
The transport type represented by the URL.
null
is returned if the transport type can't be determined.
- Type
- String
(async) onConnectAPIClick()
Invoked by a button on the API connectivity form to trigger a connection
to the currently selected (or manually entered), connection. Prior to triggering
this action, this function displays warning dialogs if a game or a table advertisement /
join request is currently active.
- Source:
(async) onConnectP2PClick()
Invoked by a button on the P2P connectivity form to trigger a connection
to the currently selected (or manually entered), connection. Prior to triggering
this action, this function displays warning dialogs if a game or a table advertisement /
join request is currently active.
- Source:
(async) onConnectUsingSDBClick()
Invoked by the SDB connect button in the connectivity options of the user
interface (the alternative to manual address entry).
- Source:
(async) onEnableServerAccessClick(cbRef)
Invoked by the toggle switch used to enable external access to API / P2P functionality.
Parameters:
Name | Type | Description |
---|---|---|
cbRef |
HTMLElement | The styled checkbox (sliding toggle), that trigerred this function. |
- Source:
(async) onSaveAPIClick()
Invoked by a button on the API connectivity form to trigger the saving of
information currently enetered into the form as a new entry which will
subsequently be included in the population of the API connections.
list.
- Source:
(async) onSaveP2PClick()
Invoked by a button on the P2P connectivity form to trigger the saving of
information currently enetered into the form as a new entry which will
subsequently be included in the population of the P2P connections.
list.
- Source:
onServerSDBOptionClick()
Invoked when any of the SDb generation options (radio buttons or checkboxes), are
clicked in the server portion of the connectivity management interface.
- Source:
populateAPIConnectionInputs()
Populates the API connection input fields (url and create script) in the user interface,
using the currently selected option in the API connections list (HTML
select
element).
- Source:
populateConnectionsList(connectionType, defaultSelectionopt)
Populates a pulldown selection list (HTML
select
element), with
connection options. The existing / default connection information specified
in the CypherPoker.settings is added to the
list first so that there will always be at least one option.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
connectionType |
String | The type of connection list to populate, either "api" or "p2p". | ||
defaultSelection |
String |
<optional> |
null | The default selection to set the list to.
If null the first (current / default) option is selected. |
- Source:
populateGatewaysList()
Populates the list of enabled gateways in the server portion of the
connectivity management interface,
- Source:
populateP2PConnectionInputs()
Populates the P2P connection input fields (url and create script) in the user interface,
using the currently selected option in the P2P connections list (HTML
select
element).
- Source:
populateServerSDB(gatewayObj)
Populates the server-generated SDB
textarea
element in the user interface when server
connectivity is enabled, or when the SDB format or options change.
Parameters:
Name | Type | Description |
---|---|---|
gatewayObj |
Object | Object containing information about the gateway such as would be added in during populateGatewaysList. |
- Source:
registerListener(eventType, router, funcRef, context)
Registers an event listener for an event handled by this class. Any changes to connectivity
will also include updates to registered listeners.
Currently supported listeners include:
Currently supported listeners include:
"message"
- dispatched by the p2p
Parameters:
Name | Type | Description |
---|---|---|
eventType |
String | The type of event to register a listener for. |
router |
String | The router type to register the listener with. Valid types
include "api" and "p2p" . |
funcRef |
function | The handler function to register for the event. |
context |
* | The context in which to execute funcRef . |
- Source:
removeEventListener(type, listener, contextopt)
Removes an event listener from the extending instance.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
type |
String | The event type to remove the function from. | ||
listener |
function | The listening function to remove. | ||
context |
Object |
<optional> |
null | The context or scope in which the listener exists. |
- Inherited From:
- Source:
(async) saveConnection(connectionInfo, connectionType) → {Boolean}
Saves a connection info object for later retieval.
Parameters:
Name | Type | Description |
---|---|---|
connectionInfo |
Object | An object containing information on how to establish the connection. |
connectionType |
String | The type of connection that connectionInfo
represents, either "api" or "p2p". |
- Source:
Returns:
True if the information was successfully saved, false otherwise.
- Type
- Boolean
serverSDBToClipboard()
Copies the current contents of the server-generated SDB
textarea
element
to the system clipboard.
- Source:
showSDBConnectStatus()
Displays connection status using the main dialog when a connection attempt
has been started using a SDB.
- Source:
(async) startConnections(apiFatalFailopt, p2pFatalFailopt)
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
apiFatalFail |
Boolean |
<optional> |
false | If true, a connection failure to the API services server is considered fatal and will throw an exception, otherwise only a connection failure warning is displayed in the console. |
p2pFatalFail |
Boolean |
<optional> |
false | If true, a connection failure to the peer-to-peer network is considered fatal and will throw an exception, otherwise only a connection failure warning is displayed in the console. |
- Source: