A register of all contected Clients
- Source:
Members
(private, inner) clients :object
An object containing all clients currently connected
Type:
- object
- Source:
Methods
(static) clientsInSpace(spaceID) → {Array.<Client>}
Return the list of Clients in a space in the current process.
Parameters:
| Name | Type | Description |
|---|---|---|
spaceID |
string | The space ID to get clients for |
- Source:
Returns:
The clients in the given space
- Type
- Array.<Client>
Example
Listing the clients in a space
ClientRegister.clientsInSpace(spaceID);
// [{ id: 'clientID' }] etc...
(static) deregisterClient(client) → {Promise.<Client>}
Deregister a client, and remove their persisted presence.
Parameters:
| Name | Type | Description |
|---|---|---|
client |
Client | The client to deregister |
- Source:
Returns:
A promise resolving with the client after deregistration
- Type
- Promise.<Client>
Example
Deregistering a client
ClientRegister.deregisterClient(client).then(client => console.log(client));
(static) getClient(clientID) → {Client}
Get a client by ID from the current process's client pool.
Parameters:
| Name | Type | Description |
|---|---|---|
clientID |
string | The ID of the client to fetch |
- Source:
Returns:
- Type
- Client
Example
Getting a client
Client.getClient('clientID');
(static) registerClient(socket) → {Promise.<Client>}
Register a new client with a given client ID, and send them a list of the currently joined members in their space.
Parameters:
| Name | Type | Description |
|---|---|---|
socket |
WS.WebSocket | The socket that the new client is connected on |
- Source:
Returns:
A promise resolved with the newly-registered Client
- Type
- Promise.<Client>
Example
Registering a client
ClientRegister.registerClient(webSocket).then(client => console.log(client));
(static) removeAllClients()
Forcibly remove all clients from the registry (but do not remove them from Redis).
- Source:
(static) renewClient(client) → {Promise.<Client>}
Renew a client's presence.
Parameters:
| Name | Type | Description |
|---|---|---|
client |
Client | The client to renew presence for |
- Source:
Returns:
A promise resolving with the client after presence renewed
- Type
- Promise.<Client>
Example
Renewing a client's presence lease
ClientRegister.renewClient(client).then(client => console.log(client));
(private, inner) getNSKeyPattern(spaceID) → {string}
Get the presence key pattern for a space.
Parameters:
| Name | Type | Description |
|---|---|---|
spaceID |
string | The ID of the space to get presence key pattern for |
- Source:
Returns:
A pattern to fetch presence keys for a space
- Type
- string
(private, inner) persistClientPresence(client) → {Promise.<Client>}
Persist a client's presence to Redis.
Parameters:
| Name | Type | Description |
|---|---|---|
client |
Client | The client to persist presence for |
- Source:
Returns:
A promise resolving with the client after persistence
- Type
- Promise.<Client>
(private, inner) setClientExpiration(client) → {Promise.<Client>}
Set a client's expiration time in Redis.
Parameters:
| Name | Type | Description |
|---|---|---|
client |
Client | The client to set expiration for |
- Source:
Returns:
A promise resolving when the expiration is set
- Type
- Promise.<Client>