Package com.slack.api.socket_mode.impl
Class SocketModeClientTyrusImpl
java.lang.Object
com.slack.api.socket_mode.impl.SocketModeClientTyrusImpl
- All Implemented Interfaces:
SocketModeClient,Closeable,AutoCloseable
Socket Mode Client
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.slack.api.socket_mode.SocketModeClient
SocketModeClient.Backend -
Field Summary
Fields inherited from interface com.slack.api.socket_mode.SocketModeClient
DEFAULT_MESSAGE_PROCESSOR_CONCURRENCY, DEFAULT_SESSION_MONITOR_INTERVAL_MILLISECONDS, EXECUTOR_GROUP_NAME_PREFIX, GSON, LOGGER, PRETTY_PRINTING -
Constructor Summary
ConstructorsConstructorDescriptionSocketModeClientTyrusImpl(Slack slack, String appToken) SocketModeClientTyrusImpl(Slack slack, String appToken, String wssUrl) SocketModeClientTyrusImpl(Slack slack, String appToken, String wssUrl, int concurrency) SocketModeClientTyrusImpl(Slack slack, String appToken, String wssUrl, int concurrency, SocketModeMessageQueue messageQueue, boolean autoReconnectEnabled, boolean sessionMonitorEnabled, long sessionMonitorIntervalMillis) SocketModeClientTyrusImpl(String appToken) -
Method Summary
Modifier and TypeMethodDescriptionvoidconnect()Connects to the current WSS endpoint and starts a new WebSocket session.voidDisconnects from the wss endpoint and abandons the current session.com.google.gson.GsongetGson()Returns the message queue for message processor workers.getSlack()Returns the current WSS URI.booleanTries to reconnect to the Socket Mode server if true.booleanReturns true if the client tries to reconnect when onClose listeners are called plus isAutoReconnectEnabled() is true.booleanA background job for session maintenance works if true.longMaintains the current session in a background job.voidonClose(javax.websocket.Session session, javax.websocket.CloseReason reason) voidvoidvoidonOpen(javax.websocket.Session session) voidonPong(javax.websocket.PongMessage message) voidsendWebSocketMessage(String message) Sends a text message to the Socket Mode server via the current WebSocket connection.voidsetAppToken(String appToken) voidsetAutoReconnectEnabled(boolean autoReconnectEnabled) voidsetAutoReconnectOnCloseEnabled(boolean autoReconnectOnCloseEnabled) voidsetMessageProcessorExecutor(ScheduledExecutorService executorService) voidsetMessageQueue(SocketModeMessageQueue messageQueue) voidsetSessionMonitorEnabled(boolean sessionMonitorEnabled) voidsetSessionMonitorExecutor(Optional<ScheduledExecutorService> executorService) voidvoidbooleanReturns true if this client is connected to the Socket Mode server.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.slack.api.socket_mode.SocketModeClient
addEventsApiEnvelopeListener, addInteractiveEnvelopeListener, addSlashCommandsEnvelopeListener, addWebSocketCloseListener, addWebSocketErrorListener, addWebSocketMessageListener, close, connectToNewEndpoint, debugLogRequest, debugLogResponse, enqueueMessage, getExecutorGroupNamePrefix, getLogger, initializeMessageProcessorExecutor, initializeSessionMonitorExecutor, processMessage, removeEventsApiEnvelopeListener, removeInteractiveEnvelopeListener, removeSlashCommandsEnvelopeListener, removeWebSocketCloseListener, removeWebSocketErrorListener, removeWebSocketMessageListener, runCloseListenersAndAutoReconnectAsNecessary, runErrorListeners, sendSocketModeResponse, sendSocketModeResponse
-
Constructor Details
-
SocketModeClientTyrusImpl
public SocketModeClientTyrusImpl(String appToken) throws URISyntaxException, IOException, SlackApiException -
SocketModeClientTyrusImpl
public SocketModeClientTyrusImpl(Slack slack, String appToken) throws URISyntaxException, IOException, SlackApiException -
SocketModeClientTyrusImpl
public SocketModeClientTyrusImpl(Slack slack, String appToken, String wssUrl) throws URISyntaxException - Throws:
URISyntaxException
-
SocketModeClientTyrusImpl
public SocketModeClientTyrusImpl(Slack slack, String appToken, String wssUrl, int concurrency) throws URISyntaxException - Throws:
URISyntaxException
-
SocketModeClientTyrusImpl
public SocketModeClientTyrusImpl(Slack slack, String appToken, String wssUrl, int concurrency, SocketModeMessageQueue messageQueue, boolean autoReconnectEnabled, boolean sessionMonitorEnabled, long sessionMonitorIntervalMillis) throws URISyntaxException - Throws:
URISyntaxException
-
-
Method Details
-
maintainCurrentSession
public long maintainCurrentSession()Description copied from interface:SocketModeClientMaintains the current session in a background job.see also: initializeSessionMonitorExecutor
- Specified by:
maintainCurrentSessionin interfaceSocketModeClient- Returns:
- unix time to check next time
-
connect
public void connect()Description copied from interface:SocketModeClientConnects to the current WSS endpoint and starts a new WebSocket session.- Specified by:
connectin interfaceSocketModeClient
-
verifyConnection
public boolean verifyConnection()Description copied from interface:SocketModeClientReturns true if this client is connected to the Socket Mode server.- Specified by:
verifyConnectionin interfaceSocketModeClient
-
isAutoReconnectOnCloseEnabled
public boolean isAutoReconnectOnCloseEnabled()Description copied from interface:SocketModeClientReturns true if the client tries to reconnect when onClose listeners are called plus isAutoReconnectEnabled() is true. Default: false- Specified by:
isAutoReconnectOnCloseEnabledin interfaceSocketModeClient
-
setAutoReconnectOnCloseEnabled
public void setAutoReconnectOnCloseEnabled(boolean autoReconnectOnCloseEnabled) - Specified by:
setAutoReconnectOnCloseEnabledin interfaceSocketModeClient
-
disconnect
Description copied from interface:SocketModeClientDisconnects from the wss endpoint and abandons the current session.- Specified by:
disconnectin interfaceSocketModeClient- Throws:
IOException
-
onOpen
public void onOpen(javax.websocket.Session session) -
onClose
public void onClose(javax.websocket.Session session, javax.websocket.CloseReason reason) -
onError
-
onMessage
-
onPong
public void onPong(javax.websocket.PongMessage message) -
getSlack
- Specified by:
getSlackin interfaceSocketModeClient
-
setSlack
- Specified by:
setSlackin interfaceSocketModeClient
-
getGson
public com.google.gson.Gson getGson()- Specified by:
getGsonin interfaceSocketModeClient
-
getAppToken
- Specified by:
getAppTokenin interfaceSocketModeClient
-
setAppToken
- Specified by:
setAppTokenin interfaceSocketModeClient
-
isAutoReconnectEnabled
public boolean isAutoReconnectEnabled()Description copied from interface:SocketModeClientTries to reconnect to the Socket Mode server if true.- Specified by:
isAutoReconnectEnabledin interfaceSocketModeClient
-
setAutoReconnectEnabled
public void setAutoReconnectEnabled(boolean autoReconnectEnabled) - Specified by:
setAutoReconnectEnabledin interfaceSocketModeClient
-
isSessionMonitorEnabled
public boolean isSessionMonitorEnabled()Description copied from interface:SocketModeClientA background job for session maintenance works if true.- Specified by:
isSessionMonitorEnabledin interfaceSocketModeClient
-
setSessionMonitorEnabled
public void setSessionMonitorEnabled(boolean sessionMonitorEnabled) - Specified by:
setSessionMonitorEnabledin interfaceSocketModeClient
-
getSessionMonitorExecutor
- Specified by:
getSessionMonitorExecutorin interfaceSocketModeClient
-
sendWebSocketMessage
Description copied from interface:SocketModeClientSends a text message to the Socket Mode server via the current WebSocket connection.- Specified by:
sendWebSocketMessagein interfaceSocketModeClient
-
getWssUri
Description copied from interface:SocketModeClientReturns the current WSS URI.- Specified by:
getWssUriin interfaceSocketModeClient
-
setWssUri
- Specified by:
setWssUriin interfaceSocketModeClient
-
getMessageQueue
Description copied from interface:SocketModeClientReturns the message queue for message processor workers.- Specified by:
getMessageQueuein interfaceSocketModeClient
-
setMessageQueue
- Specified by:
setMessageQueuein interfaceSocketModeClient
-
getMessageProcessorExecutor
- Specified by:
getMessageProcessorExecutorin interfaceSocketModeClient
-
setMessageProcessorExecutor
- Specified by:
setMessageProcessorExecutorin interfaceSocketModeClient
-
setSessionMonitorExecutor
- Specified by:
setSessionMonitorExecutorin interfaceSocketModeClient
-
getWebSocketMessageListeners
- Specified by:
getWebSocketMessageListenersin interfaceSocketModeClient
-
getWebSocketErrorListeners
- Specified by:
getWebSocketErrorListenersin interfaceSocketModeClient
-
getWebSocketCloseListeners
- Specified by:
getWebSocketCloseListenersin interfaceSocketModeClient
-
getInteractiveEnvelopeListeners
- Specified by:
getInteractiveEnvelopeListenersin interfaceSocketModeClient
-
getSlashCommandsEnvelopeListeners
- Specified by:
getSlashCommandsEnvelopeListenersin interfaceSocketModeClient
-
getEventsApiEnvelopeListeners
- Specified by:
getEventsApiEnvelopeListenersin interfaceSocketModeClient
-