Package com.slack.api.rtm
Class RTMClient
java.lang.Object
com.slack.api.rtm.RTMClient
- All Implemented Interfaces:
Closeable,AutoCloseable
Real Time Messaging (RTM) API
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCloseHandler(RTMCloseHandler closeHandler) voidaddErrorHandler(RTMErrorHandler errorHandler) voidaddMessageHandler(RTMMessageHandler messageHandler) voidclose()voidconnect()Connects to the wss endpoint and starts a new WebSocket session.voidDisconnects from the wss endpoint.voidonClose(javax.websocket.Session session, javax.websocket.CloseReason reason) voidvoidvoidonOpen(javax.websocket.Session session) voidRe-connects to a new wss endpoint and starts a new WebSocket session.voidremoveCloseHandler(RTMCloseHandler closeHandler) voidremoveErrorHandler(RTMErrorHandler errorHandler) voidremoveMessageHandler(RTMMessageHandler messageHandler) voidsendMessage(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:
IOExceptionjavax.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://docs.slack.dev/apis/web-api/rate-limits#rtm- Throws:
IOExceptionSlackApiExceptionURISyntaxExceptionjavax.websocket.DeploymentException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein 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
-