Methods
bindHandler(id, name, fn) → {undefined}
Binds a handler for a custom transport event for the provided
socket. Must not coincide with rpc.clientRequests
or
transport system event names. May be used inside chat-service.hooks.HooksInterface#onConnect
hook.
Parameters:
Name | Type | Description |
---|---|---|
id |
string | Socket id. |
name |
string | Event name. |
fn |
chat-service.TransportInterface#handler | Handler. |
Returns:
- Type
- undefined
emitToChannel(channel, eventName, …eventData) → {Promise.<undefined>}
Sends an event directly to a transport channel. May be used to implement lightweight room notifications.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
channel |
string | Corresponds to a room name. |
|
eventName |
string | Event name. |
|
eventData |
* |
<repeatable> |
Event data. |
Returns:
Promise that resolves without any data.
- Type
- Promise.<undefined>
getHandshakeData(id) → {chat-service.TransportInterface.HandshakeData}
Gets socket handshake data.
Parameters:
Name | Type | Description |
---|---|---|
id |
string | Socket id. |
Returns:
Handshake data.
getServer() → {Object}
Gets a transport server.
Returns:
Transport server.
- Type
- Object
getSocket(id) → {Object}
Gets a transport socket by id.
Parameters:
Name | Type | Description |
---|---|---|
id |
string | Socket id. |
Returns:
Socket object.
- Type
- Object
sendToChannel(id, channel, eventName, …eventData) → {Promise.<undefined>}
The same as chat-service.TransportInterface#emitToChannel
,
but excludes the sender socket from recipients.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
id |
string | Sender socket id. |
|
channel |
string | Corresponds to a room name. |
|
eventName |
string | Event name. |
|
eventData |
* |
<repeatable> |
Event data. |
Returns:
Promise that resolves without any data.
- Type
- Promise.<undefined>
Type Definitions
HandshakeData
Properties:
Name | Type | Description |
---|---|---|
isConnected |
boolean | If the socket is still connected. If it is not, then headers and query will be empty. |
headers |
Object | Parsed headers. |
query |
Object | Parsed query string. |
Connection handshake data. May include other fields.
Type:
- Object
handler(…args) → {Promise.<Array>}
Handler.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
args |
* |
<repeatable> |
Returns:
Array of results.
- Type
- Promise.<Array>