Package com.slack.api.rtm
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:
- RTM API
-
Constructor Summary
-
Method Summary
Modifier and Type Method Description void
addCloseHandler(RTMCloseHandler closeHandler)
void
addErrorHandler(RTMErrorHandler errorHandler)
void
addMessageHandler(RTMMessageHandler messageHandler)
void
close()
void
connect()
Connects to the wss endpoint and starts a new WebSocket session.void
disconnect()
Disconnects from the wss endpoint.User
getConnectedBotUser()
URI
getWssUri()
void
onClose(javax.websocket.Session session, javax.websocket.CloseReason reason)
void
onError(javax.websocket.Session session, Throwable reason)
void
onMessage(String message)
void
onOpen(javax.websocket.Session session)
void
reconnect()
Re-connects to a new wss endpoint and starts a new WebSocket session.void
removeCloseHandler(RTMCloseHandler closeHandler)
void
removeErrorHandler(RTMErrorHandler errorHandler)
void
removeMessageHandler(RTMMessageHandler messageHandler)
void
sendMessage(String message)
-
Constructor Details
-
RTMClient
public RTMClient(Slack slack, String botApiToken, String wssUrl, User connectedBotUser) throws URISyntaxException- Throws:
URISyntaxException
-
-
Method Details
-
connect
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
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.DeploymentExceptionRe-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:
IOException
SlackApiException
URISyntaxException
javax.websocket.DeploymentException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
onOpen
public void onOpen(javax.websocket.Session session) -
onClose
public void onClose(javax.websocket.Session session, javax.websocket.CloseReason reason) -
onError
-
onMessage
-
addMessageHandler
-
removeMessageHandler
-
addErrorHandler
-
removeErrorHandler
-
addCloseHandler
-
removeCloseHandler
-
sendMessage
-
getWssUri
-
getConnectedBotUser
-