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
Modifier and Type Method Description void
connect()
Connects to the current WSS endpoint and starts a new WebSocket session.void
connectToNewEndpoint()
Connects to a new WSS endpoint and starts a new WebSocket session.void
disconnect()
Disconnects from the wss endpoint and abandons the current session.String
getAppToken()
List<EnvelopeListener<EventsApiEnvelope>>
getEventsApiEnvelopeListeners()
com.google.gson.Gson
getGson()
List<EnvelopeListener<InteractiveEnvelope>>
getInteractiveEnvelopeListeners()
ScheduledExecutorService
getMessageProcessorExecutor()
SocketModeMessageQueue
getMessageQueue()
Returns the message queue for message processor workers.Optional<ScheduledExecutorService>
getSessionMonitorExecutor()
Slack
getSlack()
List<EnvelopeListener<SlashCommandsEnvelope>>
getSlashCommandsEnvelopeListeners()
List<WebSocketCloseListener>
getWebSocketCloseListeners()
List<WebSocketErrorListener>
getWebSocketErrorListeners()
List<WebSocketMessageListener>
getWebSocketMessageListeners()
URI
getWssUri()
Returns the current WSS URI.boolean
isAutoReconnectEnabled()
Tries to reconnect to the Socket Mode server if true.boolean
isSessionMonitorEnabled()
A background job for session maintenance works if true.long
maintainCurrentSession()
Maintains the current session in a background job.void
sendWebSocketMessage(String message)
Sends a text message to the Socket Mode server via the current WebSocket connection.void
setAppToken(String appToken)
void
setAutoReconnectEnabled(boolean autoReconnectEnabled)
void
setMessageProcessorExecutor(ScheduledExecutorService executorService)
void
setMessageQueue(SocketModeMessageQueue messageQueue)
void
setSessionMonitorEnabled(boolean sessionMonitorEnabled)
void
setSessionMonitorExecutor(Optional<ScheduledExecutorService> executorService)
void
setSlack(Slack slack)
void
setWssUri(URI wssUri)
boolean
verifyConnection()
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 Details
-
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 Details
-
connect
public void connect()Description copied from interface:SocketModeClient
Connects to the current WSS endpoint and starts a new WebSocket session.- Specified by:
connect
in interfaceSocketModeClient
-
verifyConnection
public boolean verifyConnection()Description copied from interface:SocketModeClient
Returns true if this client is connected to the Socket Mode server.- Specified by:
verifyConnection
in interfaceSocketModeClient
-
disconnect
public void disconnect()Description copied from interface:SocketModeClient
Disconnects from the wss endpoint and abandons the current session.- Specified by:
disconnect
in interfaceSocketModeClient
-
connectToNewEndpoint
Description copied from interface:SocketModeClient
Connects to a new WSS endpoint and starts a new WebSocket session.- Specified by:
connectToNewEndpoint
in interfaceSocketModeClient
- Throws:
IOException
-
sendWebSocketMessage
Description copied from interface:SocketModeClient
Sends a text message to the Socket Mode server via the current WebSocket connection.- Specified by:
sendWebSocketMessage
in interfaceSocketModeClient
-
maintainCurrentSession
public long maintainCurrentSession()Description copied from interface:SocketModeClient
Maintains the current session in a background job.see also: initializeSessionMonitorExecutor
- Specified by:
maintainCurrentSession
in interfaceSocketModeClient
- Returns:
- unix time to check next time
-
getSlack
- Specified by:
getSlack
in interfaceSocketModeClient
-
setSlack
- Specified by:
setSlack
in interfaceSocketModeClient
-
getGson
public com.google.gson.Gson getGson()- Specified by:
getGson
in interfaceSocketModeClient
-
getAppToken
- Specified by:
getAppToken
in interfaceSocketModeClient
-
setAppToken
- Specified by:
setAppToken
in interfaceSocketModeClient
-
getWssUri
Description copied from interface:SocketModeClient
Returns the current WSS URI.- Specified by:
getWssUri
in interfaceSocketModeClient
-
setWssUri
- Specified by:
setWssUri
in interfaceSocketModeClient
-
isAutoReconnectEnabled
public boolean isAutoReconnectEnabled()Description copied from interface:SocketModeClient
Tries to reconnect to the Socket Mode server if true.- Specified by:
isAutoReconnectEnabled
in interfaceSocketModeClient
-
setAutoReconnectEnabled
public void setAutoReconnectEnabled(boolean autoReconnectEnabled)- Specified by:
setAutoReconnectEnabled
in interfaceSocketModeClient
-
isSessionMonitorEnabled
public boolean isSessionMonitorEnabled()Description copied from interface:SocketModeClient
A background job for session maintenance works if true.- Specified by:
isSessionMonitorEnabled
in interfaceSocketModeClient
-
setSessionMonitorEnabled
public void setSessionMonitorEnabled(boolean sessionMonitorEnabled)- Specified by:
setSessionMonitorEnabled
in interfaceSocketModeClient
-
getSessionMonitorExecutor
- Specified by:
getSessionMonitorExecutor
in interfaceSocketModeClient
-
setSessionMonitorExecutor
- Specified by:
setSessionMonitorExecutor
in interfaceSocketModeClient
-
getMessageQueue
Description copied from interface:SocketModeClient
Returns the message queue for message processor workers.- Specified by:
getMessageQueue
in interfaceSocketModeClient
-
setMessageQueue
- Specified by:
setMessageQueue
in interfaceSocketModeClient
-
getMessageProcessorExecutor
- Specified by:
getMessageProcessorExecutor
in interfaceSocketModeClient
-
setMessageProcessorExecutor
- Specified by:
setMessageProcessorExecutor
in interfaceSocketModeClient
-
getWebSocketErrorListeners
- Specified by:
getWebSocketErrorListeners
in interfaceSocketModeClient
-
getWebSocketCloseListeners
- Specified by:
getWebSocketCloseListeners
in interfaceSocketModeClient
-
getWebSocketMessageListeners
- Specified by:
getWebSocketMessageListeners
in interfaceSocketModeClient
-
getEventsApiEnvelopeListeners
- Specified by:
getEventsApiEnvelopeListeners
in interfaceSocketModeClient
-
getInteractiveEnvelopeListeners
- Specified by:
getInteractiveEnvelopeListeners
in interfaceSocketModeClient
-
getSlashCommandsEnvelopeListeners
- Specified by:
getSlashCommandsEnvelopeListeners
in interfaceSocketModeClient
-