Class: SocketModeClient
A Socket Mode Client allows programs to communicate with the Slack Platform's Events API over WebSocket connections. This object uses the EventEmitter pattern to dispatch incoming events and has a built in send method to acknowledge incoming events over the WebSocket connection.
Extends
Constructors
new SocketModeClient()
new SocketModeClient(__namedParameters): SocketModeClient
Parameters
• __namedParameters: SocketModeOptions
= ...
Returns
Overrides
EventEmitter.constructor
Defined in
packages/socket-mode/src/SocketModeClient.ts:95
Properties
websocket?
optional websocket: SlackWebSocket;
The underlying WebSocket client instance
Defined in
packages/socket-mode/src/SocketModeClient.ts:65
Methods
disconnect()
disconnect(): Promise<void>
End a Socket Mode session. After this method is called no messages will be sent or received unless you call start() again later.
Returns
Promise
<void
>
Defined in
packages/socket-mode/src/SocketModeClient.ts:204
onWebSocketMessage()
protected onWebSocketMessage(data, isBinary): Promise<void>
onmessage
handler for the client's WebSocket.
This will parse the payload and dispatch the application-relevant events for each incoming message.
Mediates:
- raising the State.Connected event (when Slack sends a type:hello message)
- disconnecting the underlying socket (when Slack sends a type:disconnect message)
Parameters
• data: RawData
• isBinary: boolean
Returns
Promise
<void
>
Defined in
packages/socket-mode/src/SocketModeClient.ts:284
start()
start(): Promise<AppsConnectionsOpenResponse>
Start a Socket Mode session app.
This method must be called before any messages can be sent or received,
or to disconnect the client via the disconnect
method.
Returns
Promise
<AppsConnectionsOpenResponse
>