Skip to content

RTM Client features

Ankur Oberoi edited this page Jun 28, 2017 · 15 revisions

An overview of features of the RtmClient object beyond simply opening a WebSocket. Some of these features may not be exclusive to the RTM Client.

  • 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 alternative transport 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.
  • Convenience Methods: Defines explicit methods for sending messages of types typing, message, and presence_sub.
  • Logging: Logs information at several log levels. Logging function can be configured.
  • Lifecycle Events: TODO see docs/RtmClient Event Lifecycle.xml

TODO how do retries work?

NOTE: this is a WIP, feel free to contribute edits.

Clone this wiki locally