Extends
Methods
directMessagesChecker(message, cbopt) → {Promise.<undefined>}
Validator for directMessage
message objects. When is set, a
custom format in direct messages is enabled. When hooks resolves,
than a message format is considered valid, and the other way
around for the rejection case.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
message |
Object | Message object. |
|
cb |
callback |
<optional> |
Optional callback. |
Returns:
Promise that resolves without any data.
- Type
- Promise.<undefined>
onClose(server, erroropt, cbopt) → {Promise.<undefined>}
Executes when server is closed (after a transport is closed and all clients are disconnected, but a state is still up).
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
server |
chat-service.ChatService | Service instance. |
|
error |
Error |
<optional> |
An error occurred during closing. |
cb |
callback |
<optional> |
Optional callback. |
Returns:
Promise that resolves without any data.
- Type
- Promise.<undefined>
onConnect(server, id, cbopt) → {Promise.<(Array|string)>}
Client connection hook. Client can send requests or receive notifications only after this hook is resolved.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
server |
chat-service.ChatService | Service instance. |
|
id |
string | Socket id. |
|
cb |
callback |
<optional> |
Optional callback. |
Returns:
Resolves either a login string
(user name) or an array with a login string and an optional auth
data object. User name and auth data are send back with a rpc.serverNotifications.loginConfirmed
message. Error is sent as
a rpc.serverNotifications.loginRejected
message.
- Type
- Promise.<(Array|string)>
onDisconnect(server, data, cbopt) → {Promise.<undefined>}
Properties:
Name | Type | Description |
---|---|---|
data.id |
string | Socket id. |
data.nconnected |
number | Number of user's sockets that are still connected. |
data.roomsRemoved |
Array.<String> | Rooms that the socket was joined. |
data.joinedSockets |
Array.<number> | Corresponding number of still joined (after this socket disconnected) user's sockets to the roomsRemoved. |
Client disconnection hook.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
server |
chat-service.ChatService | Service instance. |
|
data |
Object | Socket disconnection data. |
|
cb |
callback |
<optional> |
Optional callback. |
Returns:
Promise that resolves without any data.
- Type
- Promise.<undefined>
onJoin(server, data, cbopt) → {Promise.<undefined>}
Properties:
Name | Type | Description |
---|---|---|
data.id |
string | Socket id. |
data.njoined |
number | Number of user's sockets that are joined the room (including this one). |
data.roomName |
string | Room name. |
Executes when a socket joins a room. It is run in a lock context, so the same socket leaving the same room operation will not be run until the join operation completes.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
server |
chat-service.ChatService | Service instance. |
|
data |
Object | Data. |
|
cb |
callback |
<optional> |
Optional callback. |
Returns:
Promise that resolves without any data. If the promise is rejected rollbacks a join operation.
- Type
- Promise.<undefined>
onLeave(server, data, cbopt) → {Promise.<undefined>}
Properties:
Name | Type | Description |
---|---|---|
data.id |
string | Socket id. |
data.njoined |
number | Number of user's sockets that are joined the room (excluding this one). |
data.roomName |
string | Room name. |
Executes when a socket leaves a room (including due to disconnect or permission lost). It is run in a lock context, so the same socket joining the same room operation will not be run until the leave operation completes.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
server |
chat-service.ChatService | Service instance. |
|
data |
Object | Data. |
|
cb |
callback |
<optional> |
Optional callback. |
Returns:
Promise that resolves without any data.
- Type
- Promise.<undefined>
onStart(server, cbopt) → {Promise.<undefined>}
Executes when server is started (after a state and a transport are up, but before requests processing is started).
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
server |
chat-service.ChatService | Service instance. |
|
cb |
callback |
<optional> |
Optional callback. |
Returns:
Promise that resolves without any data.
- Type
- Promise.<undefined>
roomMessagesChecker(message, cbopt) → {Promise.<undefined>}
Validator for roomMessage
message objects. When is set, a
custom format in room messages is enabled. When hooks resolves,
than a message format is considered valid, and the other way
around for the rejection case.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
message |
Object | Message object. |
|
cb |
callback |
<optional> |
Optional callback. |
Returns:
Promise that resolves without any data.
- Type
- Promise.<undefined>