wspool

package
v0.8.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 26, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountProvider

type AccountProvider interface {
	GetAccountBy(id string) (save.Account, error)
}

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) Close

func (p *Pool) Close() error

Close closes all connections and prevents new ones.

func (*Pool) ConnectIRC

func (p *Pool) ConnectIRC(accountID string) error

ConnectIRC increments the reference count for an account's IRC connection. Creates a new connection if one doesn't exist.

func (*Pool) DisconnectIRC

func (p *Pool) DisconnectIRC(accountID string)

DisconnectIRC decrements the reference count for an account's IRC connection. Closes the connection when the count reaches zero.

func (*Pool) JoinChannel

func (p *Pool) JoinChannel(accountID, channel string) error

JoinChannel joins an IRC channel and tracks it for rejoin on reconnect.

func (*Pool) SendIRC

func (p *Pool) SendIRC(accountID string, msg twitchirc.IRCer) error

SendIRC sends a message through an account's IRC connection.

func (*Pool) SetSend

func (p *Pool) SetSend(send func(tea.Msg))

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL