-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstructures.go
45 lines (37 loc) · 1.52 KB
/
structures.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
package websocket
import (
"encoding/json"
"github.com/broadeditz/go-twitch-conduits/helix"
)
// MessageType is the type of message received from the websocket
type MessageType string
const (
MessageTypeWelcome MessageType = "session_welcome"
MessageTypeKeepalive MessageType = "session_keepalive"
MessageTypeNotification MessageType = "notification"
)
// Message is the structure of a message received from the websocket
type Message struct {
Metadata MessageMetadata `json:"metadata"`
Payload json.RawMessage `json:"payload"`
}
// MessageMetadata is the metadata of a message received from the websocket
type MessageMetadata struct {
MessageID string `json:"message_id"`
MessageType MessageType `json:"message_type"`
MessageTimestamp string `json:"message_timestamp"`
SubscriptionType helix.EventType `json:"subscription_type,omitempty"`
SubscriptionVersion string `json:"subscription_version,omitempty"`
}
// SystemMessagePayload is the payload of a system/session message
type SystemMessagePayload struct {
Session *SystemMessagePayloadSession `json:"session,omitempty"`
}
// SystemMessagePayloadSession is the payload of a system/session message
type SystemMessagePayloadSession struct {
ID string `json:"id"`
Status string `json:"status"`
ConectedAt string `json:"connected_at"`
KeepaliveTimeoutSeconds int `json:"keepalive_timeout_seconds"`
ReconnectUrl string `json:"reconnect_url,omitempty"`
}