Class RTMClient

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

public class RTMClient
extends java.lang.Object
implements java.io.Closeable
Real Time Messaging (RTM) API

See Also:
RTM API
  • Constructor Details

    • RTMClient

      public RTMClient​(Slack slack, java.lang.String botApiToken, java.lang.String wssUrl, User connectedBotUser) throws java.net.URISyntaxException
      Throws:
      java.net.URISyntaxException
  • Method Details

    • connect

      public void connect() throws java.io.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:
      java.io.IOException
      javax.websocket.DeploymentException
    • disconnect

      public void disconnect() throws java.io.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:
      java.io.IOException
    • reconnect

      public void reconnect() throws java.io.IOException, SlackApiException, java.net.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://api.slack.com/docs/rate-limits#rtm
      Throws:
      java.io.IOException
      SlackApiException
      java.net.URISyntaxException
      javax.websocket.DeploymentException
    • close

      public void close() throws java.io.IOException
      Specified by:
      close in interface java.lang.AutoCloseable
      Specified by:
      close in interface java.io.Closeable
      Throws:
      java.io.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, java.lang.Throwable reason)
    • onMessage

      public void onMessage​(java.lang.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​(java.lang.String message)
    • getWssUri

      public java.net.URI getWssUri()
    • getConnectedBotUser

      public User getConnectedBotUser()