Documentation
¶
Overview ¶
Package eventsub implements low-level EventSub WebSocket operations.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Condition ¶
type Condition struct {
// Broadcaster is the broadcaster user ID associated with the event origin.
// Not all messages have a broadcaster ID.
// Note that messages which use broadcaster_id instead of broadcaster_user_id
// will be captured in Extra instead.
Broadcaster string `json:"broadcaster_user_id"`
// User is the user ID associated with receiving the event.
// Not all messages have a user ID.
User string `json:"user_id"`
// Extra holds any additional fields in the condition.
Extra jsontext.Value `json:",unknown"`
}
type Event ¶
type Event struct {
Subscription Subscription `json:"subscription"`
Event jsontext.Value `json:"event"`
}
Event is a payload of a notification message.
type ReconnectError ¶
type ReconnectError struct {
// Session is the session ID of the reconnecting session.
Session string `json:"id"`
// ReconnectURL is the URL sent by EventSub to reconnect.
ReconnectURL string `json:"reconnect_url"`
// Connected is the time at which the connection was originally created
// as an RFC3339Nano string.
Connected string `json:"connected_at"`
}
ReconnectError is an error representing a WebSocket reconnect message.
func (*ReconnectError) Error ¶
func (err *ReconnectError) Error() string
type RevocationError ¶
type RevocationError struct {
// Subscription is the subscription ID of the revoked subscription.
Subscription string `json:"id"`
// Status is the reason for the revocation.
Status string `json:"status"`
// Type is the subscription type.
Type string `json:"type"`
// Version is the version of the subscription type.
Version string `json:"version"`
// Created is the time at which the subscription was originally created
// as an RFC3339Nano string.
Created string `json:"created_at"`
}
RevocationError is an error representing a WebSocket revocation message.
func (*RevocationError) Error ¶
func (err *RevocationError) Error() string
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session is an EventSub WebSocket connection.
func Connect ¶
Connect connects to the Twitch EventSub server. If the HTTP client is nil, http.DefaultClient is used instead. keepalive is the interval in seconds to request keepalive messages. If zero, the Twitch default is used. url may be a reconnect URL given by a previous EventSub connection. If empty, the default Twitch EventSub URL is used.
func (*Session) Recv ¶
Recv gets the next notification message. Keepalive messages are handled transparently. The error may be of type ReconnectError, giving a reconnect URL.
Note that the context becoming done during a call to Recv will cause the WebSocket connection to close as well.
type Stream ¶
type Stream struct {
// ID is the stream ID.
// Only present in stream.online messages.
ID string `json:"id"`
// Broadcaster is the broadcaster's user ID.
Broadcaster string `json:"broadcaster_user_id"`
// BroadcasterLogin is the broadcaster's user login.
BroadcasterLogin string `json:"broadcaster_user_login"`
// BoradcasterName is the broadcaster's display name.
BroadcasterName string `json:"broadcaster_user_name"`
// Type is the stream type, usually "live".
Type string `json:"type"`
// Started is the time at which the stream started in RFC3339Nano format.
Started string `json:"started_at"`
}
StreamOnline is the payload for a stream.online or stream.offline notification.
type Subscription ¶
type Subscription struct {
// ID is the subscription ID.
ID string `json:"id"`
// Status is the subscription status.
// For event notifications, this is always "enabled".
Status string `json:"status"`
// Type is the event type.
Type string `json:"type"`
// Version is the version of the event type.
Version string `json:"version"`
// Cost is the event cost.
Cost int `json:"cost"`
// Condition is the event condition under which the event fired.
Condition Condition `json:"condition"`
// Transport holds the WebSocket connection details.
Transport Transport `json:"transport"`
// Created is the time at which the subscription was created in
// RFC3339Nano format.
Created string `json:"created_at"`
}