Class RTMClient

java.lang.Object
com.slack.api.rtm.RTMClient
All Implemented Interfaces:
Closeable, AutoCloseable

public class RTMClient extends Object implements Closeable
Real Time Messaging (RTM) API

See Also:
  • Constructor Details

  • Method Details

    • connect

      public void connect() throws IOException, javax.websocket.DeploymentException
      Connects to the wss endpoint and starts a new WebSocket session. If you'd like to reconnect to the endpoint with this instance, call #reconnect() instead. Calling this method won't work as you expect.
      Throws:
      IOException
      javax.websocket.DeploymentException
    • disconnect

      public void disconnect() throws IOException
      Disconnects from the wss endpoint. After calling this method, calling #connect() doesn't work. You need to call #reconnect() or instantiate a new RTMClient instead.
      Throws:
      IOException
    • reconnect

      public void reconnect() throws IOException, SlackApiException, URISyntaxException, javax.websocket.DeploymentException
      Re-connects to a new wss endpoint and starts a new WebSocket session. This method calls rtm.connect API. Please be aware of the rate limit. https://docs.slack.dev/apis/web-api/rate-limits#rtm
      Throws:
      IOException
      SlackApiException
      URISyntaxException
      javax.websocket.DeploymentException
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException
    • onOpen

      public void onOpen(javax.websocket.Session session)
    • onClose

      public void onClose(javax.websocket.Session session, javax.websocket.CloseReason reason)
    • onError

      public void onError(javax.websocket.Session session, Throwable reason)
    • onMessage

      public void onMessage(String message)
    • addMessageHandler

      public void addMessageHandler(RTMMessageHandler messageHandler)
    • removeMessageHandler

      public void removeMessageHandler(RTMMessageHandler messageHandler)
    • addErrorHandler

      public void addErrorHandler(RTMErrorHandler errorHandler)
    • removeErrorHandler

      public void removeErrorHandler(RTMErrorHandler errorHandler)
    • addCloseHandler

      public void addCloseHandler(RTMCloseHandler closeHandler)
    • removeCloseHandler

      public void removeCloseHandler(RTMCloseHandler closeHandler)
    • sendMessage

      public void sendMessage(String message)
    • getWssUri

      public URI getWssUri()
    • getConnectedBotUser

      public User getConnectedBotUser()