Package com.slack.api.socket_mode.impl
Class SocketModeClientJavaWSImpl
java.lang.Object
com.slack.api.socket_mode.impl.SocketModeClientJavaWSImpl
- All Implemented Interfaces:
SocketModeClient,java.io.Closeable,java.lang.AutoCloseable
public class SocketModeClientJavaWSImpl extends java.lang.Object implements SocketModeClient
-
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
Constructors Constructor Description SocketModeClientJavaWSImpl(Slack slack, java.lang.String appToken)SocketModeClientJavaWSImpl(Slack slack, java.lang.String appToken, java.lang.String wssUrl)SocketModeClientJavaWSImpl(Slack slack, java.lang.String appToken, java.lang.String wssUrl, int concurrency)SocketModeClientJavaWSImpl(Slack slack, java.lang.String appToken, java.lang.String wssUrl, int concurrency, SocketModeMessageQueue messageQueue, boolean autoReconnectEnabled, boolean sessionMonitorEnabled, long sessionMonitorIntervalMillis)SocketModeClientJavaWSImpl(java.lang.String appToken) -
Method Summary
Modifier and Type Method Description voidconnect()Connects to the current WSS endpoint and starts a new WebSocket session.voidconnectToNewEndpoint()Connects to a new WSS endpoint and starts a new WebSocket session.voiddisconnect()Disconnects from the wss endpoint and abandons the current session.java.lang.StringgetAppToken()java.util.List<EnvelopeListener<EventsApiEnvelope>>getEventsApiEnvelopeListeners()com.google.gson.GsongetGson()java.util.List<EnvelopeListener<InteractiveEnvelope>>getInteractiveEnvelopeListeners()java.util.concurrent.ScheduledExecutorServicegetMessageProcessorExecutor()SocketModeMessageQueuegetMessageQueue()Returns the message queue for message processor workers.java.util.Optional<java.util.concurrent.ScheduledExecutorService>getSessionMonitorExecutor()SlackgetSlack()java.util.List<EnvelopeListener<SlashCommandsEnvelope>>getSlashCommandsEnvelopeListeners()java.util.List<WebSocketCloseListener>getWebSocketCloseListeners()java.util.List<WebSocketErrorListener>getWebSocketErrorListeners()java.util.List<WebSocketMessageListener>getWebSocketMessageListeners()java.net.URIgetWssUri()Returns the current WSS URI.booleanisAutoReconnectEnabled()Tries to reconnect to the Socket Mode server if true.booleanisSessionMonitorEnabled()A background job for session maintenance works if true.longmaintainCurrentSession()Maintains the current session in a background job.voidsendWebSocketMessage(java.lang.String message)Sends a text message to the Socket Mode server via the current WebSocket connection.voidsetAppToken(java.lang.String appToken)voidsetAutoReconnectEnabled(boolean autoReconnectEnabled)voidsetMessageProcessorExecutor(java.util.concurrent.ScheduledExecutorService executorService)voidsetMessageQueue(SocketModeMessageQueue messageQueue)voidsetSessionMonitorEnabled(boolean sessionMonitorEnabled)voidsetSessionMonitorExecutor(java.util.Optional<java.util.concurrent.ScheduledExecutorService> executorService)voidsetSlack(Slack slack)voidsetWssUri(java.net.URI wssUri)booleanverifyConnection()Returns 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, debugLogRequest, debugLogResponse, enqueueMessage, getExecutorGroupNamePrefix, getLogger, initializeMessageProcessorExecutor, initializeSessionMonitorExecutor, processMessage, removeEventsApiEnvelopeListener, removeInteractiveEnvelopeListener, removeSlashCommandsEnvelopeListener, removeWebSocketCloseListener, removeWebSocketErrorListener, removeWebSocketMessageListener, runCloseListenersAndAutoReconnectAsNecessary, runErrorListeners, sendSocketModeResponse, sendSocketModeResponse
-
Constructor Details
-
SocketModeClientJavaWSImpl
public SocketModeClientJavaWSImpl(java.lang.String appToken) throws java.io.IOException, SlackApiException, java.net.URISyntaxException- Throws:
java.io.IOExceptionSlackApiExceptionjava.net.URISyntaxException
-
SocketModeClientJavaWSImpl
public SocketModeClientJavaWSImpl(Slack slack, java.lang.String appToken) throws java.io.IOException, SlackApiException, java.net.URISyntaxException- Throws:
java.io.IOExceptionSlackApiExceptionjava.net.URISyntaxException
-
SocketModeClientJavaWSImpl
public SocketModeClientJavaWSImpl(Slack slack, java.lang.String appToken, java.lang.String wssUrl) throws java.net.URISyntaxException- Throws:
java.net.URISyntaxException
-
SocketModeClientJavaWSImpl
public SocketModeClientJavaWSImpl(Slack slack, java.lang.String appToken, java.lang.String wssUrl, int concurrency) throws java.net.URISyntaxException- Throws:
java.net.URISyntaxException
-
SocketModeClientJavaWSImpl
public SocketModeClientJavaWSImpl(Slack slack, java.lang.String appToken, java.lang.String wssUrl, int concurrency, SocketModeMessageQueue messageQueue, boolean autoReconnectEnabled, boolean sessionMonitorEnabled, long sessionMonitorIntervalMillis) throws java.net.URISyntaxException- Throws:
java.net.URISyntaxException
-
-
Method Details
-
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
-
disconnect
public void disconnect()Description copied from interface:SocketModeClientDisconnects from the wss endpoint and abandons the current session.- Specified by:
disconnectin interfaceSocketModeClient
-
connectToNewEndpoint
public void connectToNewEndpoint() throws java.io.IOExceptionDescription copied from interface:SocketModeClientConnects to a new WSS endpoint and starts a new WebSocket session.- Specified by:
connectToNewEndpointin interfaceSocketModeClient- Throws:
java.io.IOException
-
sendWebSocketMessage
public void sendWebSocketMessage(java.lang.String message)Description copied from interface:SocketModeClientSends a text message to the Socket Mode server via the current WebSocket connection.- Specified by:
sendWebSocketMessagein interfaceSocketModeClient
-
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
-
getSlack
- Specified by:
getSlackin interfaceSocketModeClient
-
setSlack
- Specified by:
setSlackin interfaceSocketModeClient
-
getGson
public com.google.gson.Gson getGson()- Specified by:
getGsonin interfaceSocketModeClient
-
getAppToken
public java.lang.String getAppToken()- Specified by:
getAppTokenin interfaceSocketModeClient
-
setAppToken
public void setAppToken(java.lang.String appToken)- Specified by:
setAppTokenin interfaceSocketModeClient
-
getWssUri
public java.net.URI getWssUri()Description copied from interface:SocketModeClientReturns the current WSS URI.- Specified by:
getWssUriin interfaceSocketModeClient
-
setWssUri
public void setWssUri(java.net.URI wssUri)- Specified by:
setWssUriin 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
public java.util.Optional<java.util.concurrent.ScheduledExecutorService> getSessionMonitorExecutor()- Specified by:
getSessionMonitorExecutorin interfaceSocketModeClient
-
setSessionMonitorExecutor
public void setSessionMonitorExecutor(java.util.Optional<java.util.concurrent.ScheduledExecutorService> executorService)- Specified by:
setSessionMonitorExecutorin interfaceSocketModeClient
-
getMessageQueue
Description copied from interface:SocketModeClientReturns the message queue for message processor workers.- Specified by:
getMessageQueuein interfaceSocketModeClient
-
setMessageQueue
- Specified by:
setMessageQueuein interfaceSocketModeClient
-
getMessageProcessorExecutor
public java.util.concurrent.ScheduledExecutorService getMessageProcessorExecutor()- Specified by:
getMessageProcessorExecutorin interfaceSocketModeClient
-
setMessageProcessorExecutor
public void setMessageProcessorExecutor(java.util.concurrent.ScheduledExecutorService executorService)- Specified by:
setMessageProcessorExecutorin interfaceSocketModeClient
-
getWebSocketErrorListeners
- Specified by:
getWebSocketErrorListenersin interfaceSocketModeClient
-
getWebSocketCloseListeners
- Specified by:
getWebSocketCloseListenersin interfaceSocketModeClient
-
getWebSocketMessageListeners
- Specified by:
getWebSocketMessageListenersin interfaceSocketModeClient
-
getEventsApiEnvelopeListeners
- Specified by:
getEventsApiEnvelopeListenersin interfaceSocketModeClient
-
getInteractiveEnvelopeListeners
- Specified by:
getInteractiveEnvelopeListenersin interfaceSocketModeClient
-
getSlashCommandsEnvelopeListeners
- Specified by:
getSlashCommandsEnvelopeListenersin interfaceSocketModeClient
-