overlay

package
v0.0.0-...-b8f7dfc Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BroadcastExcept

type BroadcastExcept struct {
	Connection *Connection
	Message    []byte
}

type Connection

type Connection struct {
	Send chan []byte
	// contains filtered or unexported fields
}

Connection is a websocket connection for the OBS Overlay.

func NewOverlayConnection

func NewOverlayConnection(overlay *Overlay, conn *websocket.Conn) *Connection

NewOverlayConnection returns a new overlay connection.

func (*Connection) ReadPump

func (o *Connection) ReadPump()

ReadPump reads incoming socket data on the overlay connection.

func (*Connection) WritePump

func (o *Connection) WritePump()

WritePump writes outgoing socket data on the overlay connection.

type Event

type Event struct {
	Type    string      `json:"type"`
	Payload interface{} `json:"payload"`
}

Event is a json encoded message that gets sent to the frontend.

func NewEvent

func NewEvent(eventType string, payload interface{}) *Event

func (*Event) ToBytes

func (e *Event) ToBytes() ([]byte, error)

type OnMessageReceivedFunc

type OnMessageReceivedFunc func(*Overlay, *Connection, []byte)

type Overlay

type Overlay struct {
	Connections map[*Connection]struct{}

	Broadcast       chan []byte
	BroadcastExcept chan BroadcastExcept
	Register        chan *Connection
	Unregister      chan *Connection

	OnMessageReceived func(*Overlay, *Connection, []byte)
	// contains filtered or unexported fields
}

Overlay managed multiple websocket connections to the overlay.

func NewOverlay

func NewOverlay() *Overlay

NewOverlay returns a new Overlay.

func (*Overlay) AssignOnMessageReceived

func (o *Overlay) AssignOnMessageReceived(onMessageReceived OnMessageReceivedFunc)

func (*Overlay) ConnectionClose

func (o *Overlay) ConnectionClose(connection *Connection)

ConnectionClose closes a connection with the overlay.

func (*Overlay) Init

func (o *Overlay) Init()

Init starts an Overlay. Should be run in a separate go routine.

func (*Overlay) RegisterConnection

func (o *Overlay) RegisterConnection(connection *Connection)

RegisterConnection registers a connection with the overlay.

func (*Overlay) SendConnections

func (o *Overlay) SendConnections(message []byte)

SendConnections sends all connections an event.

func (*Overlay) SendConnectionsExcept

func (o *Overlay) SendConnectionsExcept(except *Connection, message []byte)

SendConnectionsExcept sends all connections except one an event.

func (*Overlay) UnregisterConnection

func (o *Overlay) UnregisterConnection(connection *Connection)

UnregisterConnection unregisters a connection with the overlay.

Jump to

Keyboard shortcuts

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