websocket

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2024 License: MIT Imports: 5 Imported by: 0

README

websocket

This package contains the logic for websocket conduits, implementing the helix.Transport interface.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is a websocket implementation of the Transport interface

func NewClient

func NewClient() *Client

NewClient returns a new instance of the websocket client

func (*Client) Close

func (c *Client) Close()

Close attempts to gracefully close the websocket connection

func (*Client) GetTransportUpdate

func (c *Client) GetTransportUpdate() *helix.TransportUpdate

GetTransportUpdate returns a helix.TransportUpdate for the websocket transport, used for updating conduits

func (*Client) Init

func (c *Client) Init() error

Init starts the websocket connection and sets up the read loop

func (*Client) OnChannelMessage

func (c *Client) OnChannelMessage(f func(message helix.ChannelMessage))

OnChannelMessage sets a callback to be called when a channel message is received, is not executed in gorourines. It is the responsibility of the caller to handle concurrency.

func (*Client) Ready

func (c *Client) Ready() chan struct{}

Ready returns a channel that is closed when the websocket connection is ready

type Message

type Message struct {
	Metadata MessageMetadata `json:"metadata"`
	Payload  json.RawMessage `json:"payload"`
}

Message is the structure of a message received from the websocket

type MessageMetadata

type MessageMetadata struct {
	MessageID           string          `json:"message_id"`
	MessageType         MessageType     `json:"message_type"`
	MessageTimestamp    string          `json:"message_timestamp"`
	SubscriptionType    helix.EventType `json:"subscription_type,omitempty"`
	SubscriptionVersion string          `json:"subscription_version,omitempty"`
}

MessageMetadata is the metadata of a message received from the websocket

type MessageType

type MessageType string

MessageType is the type of message received from the websocket

const (
	MessageTypeWelcome      MessageType = "session_welcome"
	MessageTypeKeepalive    MessageType = "session_keepalive"
	MessageTypeNotification MessageType = "notification"
)

type SystemMessagePayload

type SystemMessagePayload struct {
	Session *SystemMessagePayloadSession `json:"session,omitempty"`
}

SystemMessagePayload is the payload of a system/session message

type SystemMessagePayloadSession

type SystemMessagePayloadSession struct {
	ID                      string `json:"id"`
	Status                  string `json:"status"`
	ConectedAt              string `json:"connected_at"`
	KeepaliveTimeoutSeconds int    `json:"keepalive_timeout_seconds"`
	ReconnectUrl            string `json:"reconnect_url,omitempty"`
}

SystemMessagePayloadSession is the payload of a system/session message

Jump to

Keyboard shortcuts

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