-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcallbacks.go
148 lines (121 loc) · 6.48 KB
/
callbacks.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
package gotau
import "fmt"
// RawCallback is a callback that will be called for every message that is received. Setting this callback does
//not prevent other callbacks from being called, though this one will be called first.
type RawCallback func(msg []byte)
// ErrorCallback is a callback to handle websocket specific errors where the websocket likely needs to be re-established
//and a new client is needed.
type ErrorCallback func(err error)
// StreamOnlineCallback is a callback to handle the stream coming online event
type StreamOnlineCallback func(msg *StreamOnlineMsg)
// StreamOfflineCallback is a callback to handle the stream going offline event
type StreamOfflineCallback func(msg *StreamOfflineMsg)
// FollowCallback is a callback to handle follow events
type FollowCallback func(msg *FollowMsg)
// StreamUpdateCallback is a callback to handle updates to the stream information (like title)
type StreamUpdateCallback func(msg *StreamUpdateMsg)
// CheerCallback is a callback to handle cheer events
type CheerCallback func(msg *CheerMsg)
// RaidCallback is a callback to handle raid events
type RaidCallback func(msg *RaidMsg)
// SubscriptionCallback is a callback to handle subscription events
type SubscriptionCallback func(msg *SubscriptionMsg)
// PointsRedemptionCallback is a callback to handle points redemption events
type PointsRedemptionCallback func(msg *PointsRedemptionMsg)
// HypeTrainBeginCallback is a callback to handle hype train begin events
type HypeTrainBeginCallback func(msg *HypeTrainBeginMsg)
// HypeTrainProgressCallback is a callback to handle hype train progress events
type HypeTrainProgressCallback func(msg *HypeTrainProgressMsg)
// HypeTrainEndCallback is a callback to handle hype train end events
type HypeTrainEndCallback func(msg *HypeTrainEndedMsg)
// SetRawCallback sets a callback to be called on all received messages.
func (c *Client) SetRawCallback(callback RawCallback) {
c.rawCallback = callback
// Attempt to fix the heisenbug where if I don't acknowledge the callback it will be null
// TODO: Figure out an ACTUAL fix
_ = fmt.Sprintf("%p", c.rawCallback)
}
// SetErrorCallback sets a callback for the user to handle errors that might arise (like connection closed)
func (c *Client) SetErrorCallback(callback ErrorCallback) {
c.errorCallback = callback
// Attempt to fix the heisenbug where if I don't acknowledge the callback it will be null
// TODO: Figure out an ACTUAL fix
_ = fmt.Sprintf("%p", c.errorCallback)
}
// SetStreamOnlineCallback sets a callback to be called when a stream online event is received.
func (c *Client) SetStreamOnlineCallback(callback StreamOnlineCallback) {
c.streamOnlineCallback = callback
// Attempt to fix the heisenbug where if I don't acknowledge the callback it will be null
// TODO: Figure out an ACTUAL fix
_ = fmt.Sprintf("%p", c.streamOnlineCallback)
}
// SetStreamOfflineCallback sets a callback to be called when a stream offline event is received.
func (c *Client) SetStreamOfflineCallback(callback StreamOfflineCallback) {
c.streamOfflineCallback = callback
// Attempt to fix the heisenbug where if I don't acknowledge the callback it will be null
// TODO: Figure out an ACTUAL fix
_ = fmt.Sprintf("%p", c.streamOfflineCallback)
}
// SetFollowCallback sets a callback to be called on a follow event received.
func (c *Client) SetFollowCallback(callback FollowCallback) {
c.followCallback = callback
// Attempt to fix the heisenbug where if I don't acknowledge the callback it will be null
// TODO: Figure out an ACTUAL fix
_ = fmt.Sprintf("%p", c.followCallback)
}
// SetStreamUpdateCallback sets a callback to be called on stream update events received
func (c *Client) SetStreamUpdateCallback(callback StreamUpdateCallback) {
c.streamUpdateCallback = callback
// Attempt to fix the heisenbug where if I don't acknowledge the callback it will be null
// TODO: Figure out an ACTUAL fix
_ = fmt.Sprintf("%p", c.streamUpdateCallback)
}
// SetCheerCallback sets a callback to be called when a cheer event is received.
func (c *Client) SetCheerCallback(callback CheerCallback) {
c.cheerCallback = callback
// Attempt to fix the heisenbug where if I don't acknowledge the callback it will be null
// TODO: Figure out an ACTUAL fix
_ = fmt.Sprintf("%p", c.cheerCallback)
}
// SetRaidCallback sets a callback to be called when a raid event is received.
func (c *Client) SetRaidCallback(callback RaidCallback) {
c.raidCallback = callback
// Attempt to fix the heisenbug where if I don't acknowledge the callback it will be null
// TODO: Figure out an ACTUAL fix
_ = fmt.Sprintf("%p", c.raidCallback)
}
// SetSubscriptionCallback sets a callback to be called when a subscription event is received.
func (c *Client) SetSubscriptionCallback(callback SubscriptionCallback) {
c.subscriptionCallback = callback
// Attempt to fix the heisenbug where if I don't acknowledge the callback it will be null
// TODO: Figure out an ACTUAL fix
_ = fmt.Sprintf("%p", c.subscriptionCallback)
}
// SetPointsRedemptionCallback sets a callback to be called when a points redemption event is received.
func (c *Client) SetPointsRedemptionCallback(callback PointsRedemptionCallback) {
c.pointsRedemptionCallback = callback
// Attempt to fix the heisenbug where if I don't acknowledge the callback it will be null
// TODO: Figure out an ACTUAL fix
_ = fmt.Sprintf("%p", c.pointsRedemptionCallback)
}
// SetHypeTrainBeginCallback sets a callback to be called when a hype train begin event is received.
func (c *Client) SetHypeTrainBeginCallback(callback HypeTrainBeginCallback) {
c.hypeTrainBeginCallback = callback
// Attempt to fix the heisenbug where if I don't acknowledge the callback it will be null
// TODO: Figure out an ACTUAL fix
_ = fmt.Sprintf("%p", c.hypeTrainBeginCallback)
}
// SetHypeTrainProgressCallback sets a callback to be called when a hype train progress event is received.
func (c *Client) SetHypeTrainProgressCallback(callback HypeTrainProgressCallback) {
c.hypeTrainProgressCallback = callback
// Attempt to fix the heisenbug where if I don't acknowledge the callback it will be null
// TODO: Figure out an ACTUAL fix
_ = fmt.Sprintf("%p", c.hypeTrainProgressCallback)
}
// SetHypeTrainEndedCallback sets a callback to be called when a hype train ended event is received.
func (c *Client) SetHypeTrainEndedCallback(callback HypeTrainEndCallback) {
c.hypeTrainEndedCallback = callback
// Attempt to fix the heisenbug where if I don't acknowledge the callback it will be null
// TODO: Figure out an ACTUAL fix
_ = fmt.Sprintf("%p", c.hypeTrainEndedCallback)
}