go-twitch/eventsub/websocket/messages/mesages.go

46 lines
1.4 KiB
Go
Raw Permalink Normal View History

2024-03-05 12:14:18 -05:00
package messages
import (
"time"
)
type Metadata struct {
MessageID string `json:"message_id"`
MessageType Type `json:"message_type"`
MessageTimestamp time.Time `json:"message_timestamp"`
}
type Type string
const (
TypeSessionWelcome Type = "session_welcome"
TypeSessionKeepAlive Type = "session_keepalive"
TypeNotification Type = "notification"
TypeSessionReconnect Type = "session_reconnect"
TypeRevocation Type = "revocation"
)
type Message struct {
Metadata Metadata `json:"metadata"`
Payload any `json:"payload"`
}
type Session struct {
// An ID that uniquely identifies this WebSocket connection. Use this ID to set the session_id field in all subscription requests.
ID string `json:"id"`
// The connections status, which is set to connected.
Status string `json:"status"`
// The maximum number of seconds that you should expect silence before receiving a keepalive message.
// For a welcome message, this is the number of seconds that you have to subscribe to an event after receiving the welcome message.
// If you dont subscribe to an event within this window, the socket is disconnected.
KeepaliveTimeoutSeconds int `json:"keepalive_timeout_seconds"`
// The URL to reconnect to if you get a Reconnect message. Is set to null.
ReconnectURL *string `json:"reconnect_url"`
// The UTC date and time that the connection was created.
ConnectedAt time.Time `json:"connected_at"`
}