Documentation
¶
Index ¶
- type AccountProvider
- type EventSubEvent
- type EventSubService
- type IRCEvent
- type Pool
- func (p *Pool) Close() error
- func (p *Pool) ConnectIRC(accountID string) error
- func (p *Pool) DisconnectIRC(accountID string)
- func (p *Pool) JoinChannel(accountID, channel string) error
- func (p *Pool) SendIRC(accountID string, msg twitchirc.IRCer) error
- func (p *Pool) SetSend(send func(tea.Msg))
- func (p *Pool) SubscribeEventSub(accountID string, req twitchapi.CreateEventSubSubscriptionRequest, ...) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccountProvider ¶
AccountProvider retrieves account credentials for authentication.
type EventSubEvent ¶
type EventSubEvent struct {
AccountID string
Message eventsub.Message[eventsub.NotificationPayload] // zero value if Error is set
Error error
}
EventSubEvent is sent to UI via tea.Send when an EventSub notification is received or a connection error occurs.
type EventSubService ¶
type EventSubService interface {
CreateEventSubSubscription(ctx context.Context, reqData twitchapi.CreateEventSubSubscriptionRequest) (twitchapi.CreateEventSubSubscriptionResponse, error)
}
EventSubService creates EventSub subscriptions via the Twitch API.
type IRCEvent ¶
type IRCEvent struct {
AccountID string
Message twitchirc.IRCer // nil if Error is set
Error error // connection error, will attempt reconnect
}
IRCEvent is sent to UI via tea.Send when an IRC message is received or a connection error occurs.
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
Pool manages WebSocket connections for IRC chat and EventSub. Connections are lazily created per account and reference-counted.
func NewPool ¶
func NewPool(accounts AccountProvider, logger zerolog.Logger) *Pool
NewPool creates a new connection pool. Call SetSend() before using Connect/Subscribe methods.
func (*Pool) ConnectIRC ¶
ConnectIRC increments the reference count for an account's IRC connection. Creates a new connection if one doesn't exist.
func (*Pool) DisconnectIRC ¶
DisconnectIRC decrements the reference count for an account's IRC connection. Closes the connection when the count reaches zero.
func (*Pool) JoinChannel ¶
JoinChannel joins an IRC channel and tracks it for rejoin on reconnect.
func (*Pool) SetSend ¶
SetSend sets the callback for sending messages to the UI. Must be called after tea.NewProgram() is created, before any connections. Typically: pool.SetSend(program.Send)
func (*Pool) SubscribeEventSub ¶
func (p *Pool) SubscribeEventSub(accountID string, req twitchapi.CreateEventSubSubscriptionRequest, service EventSubService) error
SubscribeEventSub creates an EventSub subscription. Creates a new connection for the account if one doesn't exist.