Debian Codegraph @

websocket_internals.go

raw symbols SCIP
1 package slack
2
3 import (
4 "fmt"
5 "time"
6 )
7
8 /**
9 * Internal events, created by this lib and not mapped to Slack APIs.
10 */
11
12 // ConnectedEvent is used for when we connect to Slack
13 type ConnectedEvent struct {
14 ConnectionCount int // 1 = first time, 2 = second time
15 Info *Info
16 }
17
18 // ConnectionErrorEvent contains information about a connection error
19 type ConnectionErrorEvent struct {
20 Attempt int
21 Backoff time.Duration // how long we'll wait before the next attempt
22 ErrorObj error
23 }
24
25 func (c *ConnectionErrorEvent) Error() string {
26 return c.ErrorObj.Error()
27 }
28
29 // ConnectingEvent contains information about our connection attempt
30 type ConnectingEvent struct {
31 Attempt int // 1 = first attempt, 2 = second attempt
32 ConnectionCount int
33 }
34
35 // DisconnectedEvent contains information about how we disconnected
36 type DisconnectedEvent struct {
37 Intentional bool
38 Cause error
39 }
40
41 // LatencyReport contains information about connection latency
42 type LatencyReport struct {
43 Value time.Duration
44 }
45
46 // InvalidAuthEvent is used in case we can't even authenticate with the API
47 type InvalidAuthEvent struct{}
48
49 // UnmarshallingErrorEvent is used when there are issues deconstructing a response
50 type UnmarshallingErrorEvent struct {
51 ErrorObj error
52 }
53
54 func (u UnmarshallingErrorEvent) Error() string {
55 return u.ErrorObj.Error()
56 }
57
58 // MessageTooLongEvent is used when sending a message that is too long
59 type MessageTooLongEvent struct {
60 Message OutgoingMessage
61 MaxLength int
62 }
63
64 func (m *MessageTooLongEvent) Error() string {
65 return fmt.Sprintf("Message too long (max %d characters)", m.MaxLength)
66 }
67
68 // RateLimitEvent is used when Slack warns that rate-limits are being hit.
69 type RateLimitEvent struct{}
70
71 func (e *RateLimitEvent) Error() string {
72 return "Messages are being sent too fast."
73 }
74
75 // OutgoingErrorEvent contains information in case there were errors sending messages
76 type OutgoingErrorEvent struct {
77 Message OutgoingMessage
78 ErrorObj error
79 }
80
81 func (o OutgoingErrorEvent) Error() string {
82 return o.ErrorObj.Error()
83 }
84
85 // IncomingEventError contains information about an unexpected error receiving a websocket event
86 type IncomingEventError struct {
87 ErrorObj error
88 }
89
90 func (i *IncomingEventError) Error() string {
91 return i.ErrorObj.Error()
92 }
93
94 // AckErrorEvent i
95 type AckErrorEvent struct {
96 ErrorObj error
97 ReplyTo int
98 }
99
100 func (a *AckErrorEvent) Error() string {
101 return a.ErrorObj.Error()
102 }