Package com.slack.api.socket_mode.impl
Class SocketModeClientJavaWSImpl
- java.lang.Object
-
- com.slack.api.socket_mode.impl.SocketModeClientJavaWSImpl
-
- All Implemented Interfaces:
SocketModeClient,Closeable,AutoCloseable
public class SocketModeClientJavaWSImpl extends 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, String appToken)SocketModeClientJavaWSImpl(Slack slack, String appToken, String wssUrl)SocketModeClientJavaWSImpl(Slack slack, String appToken, String wssUrl, int concurrency)SocketModeClientJavaWSImpl(Slack slack, String appToken, String wssUrl, int concurrency, SocketModeMessageQueue messageQueue, boolean autoReconnectEnabled, boolean sessionMonitorEnabled, long sessionMonitorIntervalMillis)SocketModeClientJavaWSImpl(String appToken)
-
Method Summary
All Methods Instance Methods Concrete Methods 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.StringgetAppToken()List<EnvelopeListener<EventsApiEnvelope>>getEventsApiEnvelopeListeners()com.google.gson.GsongetGson()List<EnvelopeListener<InteractiveEnvelope>>getInteractiveEnvelopeListeners()ScheduledExecutorServicegetMessageProcessorExecutor()SocketModeMessageQueuegetMessageQueue()Returns the message queue for message processor workers.Optional<ScheduledExecutorService>getSessionMonitorExecutor()SlackgetSlack()List<EnvelopeListener<SlashCommandsEnvelope>>getSlashCommandsEnvelopeListeners()List<WebSocketCloseListener>getWebSocketCloseListeners()List<WebSocketErrorListener>getWebSocketErrorListeners()List<WebSocketMessageListener>getWebSocketMessageListeners()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(String message)Sends a text message to the Socket Mode server via the current WebSocket connection.voidsetAppToken(String appToken)voidsetAutoReconnectEnabled(boolean autoReconnectEnabled)voidsetMessageProcessorExecutor(ScheduledExecutorService executorService)voidsetMessageQueue(SocketModeMessageQueue messageQueue)voidsetSessionMonitorEnabled(boolean sessionMonitorEnabled)voidsetSessionMonitorExecutor(Optional<ScheduledExecutorService> executorService)voidsetSlack(Slack slack)voidsetWssUri(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, wait
-
Methods 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 Detail
-
SocketModeClientJavaWSImpl
public SocketModeClientJavaWSImpl(String appToken) throws IOException, SlackApiException, URISyntaxException
-
SocketModeClientJavaWSImpl
public SocketModeClientJavaWSImpl(Slack slack, String appToken) throws IOException, SlackApiException, URISyntaxException
-
SocketModeClientJavaWSImpl
public SocketModeClientJavaWSImpl(Slack slack, String appToken, String wssUrl) throws URISyntaxException
- Throws:
URISyntaxException
-
SocketModeClientJavaWSImpl
public SocketModeClientJavaWSImpl(Slack slack, String appToken, String wssUrl, int concurrency) throws URISyntaxException
- Throws:
URISyntaxException
-
SocketModeClientJavaWSImpl
public SocketModeClientJavaWSImpl(Slack slack, String appToken, String wssUrl, int concurrency, SocketModeMessageQueue messageQueue, boolean autoReconnectEnabled, boolean sessionMonitorEnabled, long sessionMonitorIntervalMillis) throws URISyntaxException
- Throws:
URISyntaxException
-
-
Method Detail
-
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 IOExceptionDescription copied from interface:SocketModeClientConnects to a new WSS endpoint and starts a new WebSocket session.- Specified by:
connectToNewEndpointin interfaceSocketModeClient- Throws:
IOException
-
sendWebSocketMessage
public void sendWebSocketMessage(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
public Slack getSlack()
- Specified by:
getSlackin interfaceSocketModeClient
-
setSlack
public void setSlack(Slack slack)
- Specified by:
setSlackin interfaceSocketModeClient
-
getGson
public com.google.gson.Gson getGson()
- Specified by:
getGsonin interfaceSocketModeClient
-
getAppToken
public String getAppToken()
- Specified by:
getAppTokenin interfaceSocketModeClient
-
setAppToken
public void setAppToken(String appToken)
- Specified by:
setAppTokenin interfaceSocketModeClient
-
getWssUri
public URI getWssUri()
Description copied from interface:SocketModeClientReturns the current WSS URI.- Specified by:
getWssUriin interfaceSocketModeClient
-
setWssUri
public void setWssUri(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 Optional<ScheduledExecutorService> getSessionMonitorExecutor()
- Specified by:
getSessionMonitorExecutorin interfaceSocketModeClient
-
setSessionMonitorExecutor
public void setSessionMonitorExecutor(Optional<ScheduledExecutorService> executorService)
- Specified by:
setSessionMonitorExecutorin interfaceSocketModeClient
-
getMessageQueue
public SocketModeMessageQueue getMessageQueue()
Description copied from interface:SocketModeClientReturns the message queue for message processor workers.- Specified by:
getMessageQueuein interfaceSocketModeClient
-
setMessageQueue
public void setMessageQueue(SocketModeMessageQueue messageQueue)
- Specified by:
setMessageQueuein interfaceSocketModeClient
-
getMessageProcessorExecutor
public ScheduledExecutorService getMessageProcessorExecutor()
- Specified by:
getMessageProcessorExecutorin interfaceSocketModeClient
-
setMessageProcessorExecutor
public void setMessageProcessorExecutor(ScheduledExecutorService executorService)
- Specified by:
setMessageProcessorExecutorin interfaceSocketModeClient
-
getWebSocketErrorListeners
public List<WebSocketErrorListener> getWebSocketErrorListeners()
- Specified by:
getWebSocketErrorListenersin interfaceSocketModeClient
-
getWebSocketCloseListeners
public List<WebSocketCloseListener> getWebSocketCloseListeners()
- Specified by:
getWebSocketCloseListenersin interfaceSocketModeClient
-
getWebSocketMessageListeners
public List<WebSocketMessageListener> getWebSocketMessageListeners()
- Specified by:
getWebSocketMessageListenersin interfaceSocketModeClient
-
getEventsApiEnvelopeListeners
public List<EnvelopeListener<EventsApiEnvelope>> getEventsApiEnvelopeListeners()
- Specified by:
getEventsApiEnvelopeListenersin interfaceSocketModeClient
-
getInteractiveEnvelopeListeners
public List<EnvelopeListener<InteractiveEnvelope>> getInteractiveEnvelopeListeners()
- Specified by:
getInteractiveEnvelopeListenersin interfaceSocketModeClient
-
getSlashCommandsEnvelopeListeners
public List<EnvelopeListener<SlashCommandsEnvelope>> getSlashCommandsEnvelopeListeners()
- Specified by:
getSlashCommandsEnvelopeListenersin interfaceSocketModeClient
-
-