new Context()
A set of messages and calls Servers and clients are created from a Context
- Source:
Extends
- core:Context
Methods
connect(socketOptions, authopt, callbackopt) → {core:Peer}
Create a new client from this context. To connect to a server using TLS, set 'secure' as true in socketOptions
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
socketOptions |
Object | an object passed to net.connect or tls.connect (if secure is true) |
|
auth |
AuthOptions |
<optional> |
an object describing how the client should autenticate |
callback |
function |
<optional> |
added as a listener to event:Client#connect |
- Source:
Returns:
- Type
- core:Peer
connectWS(socketOptions, authopt, callbackopt) → {core:Peer}
Create a new websocket client from this context. To connect to a server using TLS, set 'secure' as true in socketOptions
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
socketOptions |
Object | an object passed to net.connect or tls.connect (if secure is true) |
|
auth |
AuthOptions |
<optional> |
an object describing how the client should autenticate |
callback |
function |
<optional> |
added as a listener to event:WSClient#connect |
- Source:
Returns:
- Type
- core:Peer
createServer(socketOptionsopt, authopt, callbackopt) → {Server}
Create a new server from this context. To create a server using TLS, at least one of 'pfx', 'key', 'cert' must be set in socketOptions
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
socketOptions |
Object |
<optional> |
an object passed to net.createServer or tls.createServer |
auth |
AuthOptions |
<optional> |
an object describing how the server will handle autentication |
callback |
function |
<optional> |
added as a listener to event:Server#connection |
- Source:
Returns:
- Type
- Server
createWSServer(socketOptionsopt, authopt, callbackopt) → {ws:Server}
Create a new websocket server from this context. To create a server using TLS, at least one of 'pfx', 'key', 'cert' must be set in socketOptions
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
socketOptions |
Object |
<optional> |
an object passed to net.createServer or tls.createServer |
auth |
AuthOptions |
<optional> |
an object describing how the server will handle autentication |
callback |
function |
<optional> |
added as a listener to event:WSServer#connection |
- Source:
Returns:
- Type
- ws:Server