twitchws

package module
v0.0.0-...-6e6c142 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

README

lint tests Go Reference

Twitch WebSocket EventSub Client

👷 WIP

Design

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAlreadyInUse     = errors.New("client already in use")      // WebSocket client is already in use.
	ErrNotConnected     = errors.New("client is not connected")    // WebSocket client is not connected
	ErrConnectionFailed = errors.New("failed to setup connection") // Failed to set up WebSocket connection
)

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(url string, opts ...Option) *Client

func NewClientDefault

func NewClientDefault(opts ...Option) *Client

func (*Client) Close

func (c *Client) Close() error

func (*Client) Connect

func (c *Client) Connect() error

func (*Client) Wait

func (c *Client) Wait() error

type Metadata

type Metadata struct {
	MessageID           string `json:"message_id"`
	MessageType         string `json:"message_type"`
	MessageTimestamp    string `json:"message_timestamp"`
	SubscriptionType    string `json:"subscription_type"`
	SubscriptionVersion string `json:"subscription_version"`
}

type Notification

type Notification struct {
	Subscription Subscription `json:"subscription"`
	Event        interface{}  `json:"event"`
}

type OnEventFn

type OnEventFn func()

type OnMessageEventFn

type OnMessageEventFn func(*Metadata, *Payload)

type Option

type Option func(*Client)

func WithOnConnect

func WithOnConnect(fn OnEventFn) Option

func WithOnDisconnect

func WithOnDisconnect(fn OnEventFn) Option

func WithOnKeepalive

func WithOnKeepalive(fn OnMessageEventFn) Option

func WithOnNotification

func WithOnNotification(fn OnMessageEventFn) Option

func WithOnReconnect

func WithOnReconnect(fn OnMessageEventFn) Option

func WithOnRevocation

func WithOnRevocation(fn OnMessageEventFn) Option

func WithOnWelcome

func WithOnWelcome(fn OnMessageEventFn) Option

type Payload

type Payload struct {
	Payload interface{}
}

type Session

type Session struct {
	ID                      string `json:"id"`
	Status                  string `json:"status"`
	ReconnectURL            string `json:"reconnect_url"`
	ConnectedAt             string `json:"connected_at"`
	KeepaliveTimeoutSeconds int    `json:"keepalive_timeout_seconds"`
}

type Subscription

type Subscription struct {
	ID        string      `json:"id"`
	Status    string      `json:"status"`
	Type      string      `json:"type"`
	Version   string      `json:"version"`
	Condition interface{} `json:"condition"`
	Transport transport   `json:"transport"`
	CreatedAt string      `json:"created_at"`
	Cost      int         `json:"cost"`
}

Directories

Path Synopsis
examples
internal
pkg

Jump to

Keyboard shortcuts

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