-
Notifications
You must be signed in to change notification settings - Fork 663
RTM Client features
Ankur Oberoi edited this page Jul 12, 2017
·
15 revisions
An overview of features of the RtmClient
object beyond simply opening a WebSocket.
-
Event Emission: Team events in scope of the token used to connect are emitted by the client by message
type
and, for messages of type"message"
, by"message::{subtype}"
. - Response Management: Callback functions (or Promises) are associated with every sent message and invoked (or completed) once the Platform responds with an acknowledgement or an error. The responses are designed to be resilient to reconnects.
- Ping/Pong Management: At the WebSocket protocol level, the client will respond to pings from the server with a matching pong. In addition, the Slack RTM API defines messages types for "ping" and "pong". This client will send the server a "ping" message on an interval (default interval length is 5 seconds). It expects the server to "pong" within a timeout (default timeout is 20 seconds). The server can "pong" either with an explicit "pong" message or any other non-internal message. If the timeout is reached, the client begins automatic reconnection. The time constants can be configured.
-
Data Store: A caching mechanism for team data with an abstract interface:
SlackDataStore
.-
MemoryDataStore
is a default implementation - Consumes RTM messages and processes them to build a model of the team, users, and channels.
-
- Automatic Reconnection: The client attempts to reconnect if the server initiates a disconnect, if a team migration begins, if the pong timeout is exceeded, or if a recoverable error happens during connection. This feature can be turned off.
-
Proxy Support: Exposes an API to
HttpsProxyAgent
to create an alternativetransport
in order to proxy traffic via another HTTP server. This currently only supports HTTP tunnels. -
Message Updating: Exposes functionality for the
chat.update
Web API method.- The client has a
slackAPIUrl
configuration property which can be used to change the base URL of requests sent to the Web API.
- The client has a
-
Convenience Methods: Defines explicit methods for sending messages of types
typing
,message
, andpresence_sub
. -
Pluggable Socket Factory: The default WebSocket factory comes from the popular
ws
module. The client allows this to be replaced, which is mostly useful for testing. - Logging: Logs information at several log levels. Logging function can be configured.
-
User Agent Instrumentation: The client reports information about itself via the
User-Agent
request header. The format is@slack:client/${package version} ${os}/${os version} node/${node version}
-
Lifecycle Events: TODO see
docs/RtmClient Event Lifecycle.xml
TODO how do retries work?
NOTE: this is a WIP, feel free to contribute edits.