Debian Codegraph @

socketmode/client.go

raw symbols SCIP
1 package socketmode
2
3 import (
4 "encoding/json"
5 "time"
6
7 "github.com/slack-go/slack"
8
9 "github.com/gorilla/websocket"
10 )
11
12 type ConnectedEvent struct {
13 ConnectionCount int // 1 = first time, 2 = second time
14 Info *slack.SocketModeConnection
15 }
16
17 type DebugInfo struct {
18 // Host is the name of the host name on the Slack end, that can be something like `applink-7fc4fdbb64-4x5xq`
19 Host string `json:"host"`
20
21 // `hello` type only
22 BuildNumber int `json:"build_number"`
23 ApproximateConnectionTime int `json:"approximate_connection_time"`
24 }
25
26 type ConnectionInfo struct {
27 AppID string `json:"app_id"`
28 }
29
30 type SocketModeMessagePayload struct {
31 Event json.RawMessage `json:"event"`
32 }
33
34 // Client is a Socket Mode client that allows programs to use [Events API](https://api.slack.com/events-api)
35 // and [interactive components](https://api.slack.com/interactivity) over WebSocket.
36 // Please see [Intro to Socket Mode](https://api.slack.com/apis/connections/socket) for more information
37 // on Socket Mode.
38 //
39 // The implementation is highly inspired by https://www.npmjs.com/package/@slack/socket-mode,
40 // but the structure and the design has been adapted as much as possible to that of our RTM client for consistency
41 // within the library.
42 //
43 // You can instantiate the socket mode client with
44 // Client's New() and call Run() to start it. Please see examples/socketmode for the usage.
45 type Client struct {
46 // Client is the main API, embedded
47 slack.Client
48
49 // maxPingInterval is the maximum duration elapsed after the last WebSocket PING sent from Slack
50 // until Client considers the WebSocket connection is dead and needs to be reopened.
51 maxPingInterval time.Duration
52
53 // Connection life-cycle
54 Events chan Event
55 socketModeResponses chan *Response
56
57 // dialer is a gorilla/websocket Dialer. If nil, use the default
58 // Dialer.
59 dialer *websocket.Dialer
60
61 debug bool
62 log ilogger
63 }