Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var LibraryVersion = func() string { bi, ok := debug.ReadBuildInfo() if !ok { return "unknown" } for _, dep := range bi.Deps { if dep.Path == lib { return strings.TrimPrefix(dep.Version, "v") } } return "unknown" }()
var ProtocolVersion = "5.4.2"
Functions ¶
This section is empty.
Types ¶
type Categories ¶
type Categories struct { Config *config.Client Filters *filters.Client General *general.Client Inputs *inputs.Client MediaInputs *mediainputs.Client Outputs *outputs.Client Record *record.Client SceneItems *sceneitems.Client Scenes *scenes.Client Sources *sources.Client Stream *stream.Client Transitions *transitions.Client Ui *ui.Client }
type Client ¶
type Client struct { // See [Client.Listen] for more information. IncomingEvents chan any Categories // contains filtered or unexported fields }
Client represents a client to an OBS websockets server.
func New ¶
New creates and configures a client to interact with the OBS websockets server. It also opens up a connection, so be sure to check the error.
func (*Client) Disconnect ¶
Disconnect sends a message to the OBS websocket server to close the client's open connection. You should defer a disconnection after creating your client to ensure the program doesn't leave any lingering connections open and potentially leak memory, e.g.:
client, err := goobs.New("localhost:4455", goobs.WithPassword("secret")) if err != nil { panic(err) } defer client.Disconnect()
func (*Client) Listen ¶
Listen hooks into the incoming events from the server. You'll have to make type assertions to ensure you're getting the right events, e.g.:
client.Listen(func(event any) { switch val := event.(type) { case *events.InputVolumeChanged: // event i was looking for default: // other events } })
If looking for high volume events, make sure you've initialized the client with the appropriate subscriptions with WithEventSubscriptions.
type Option ¶
type Option func(*Client)
Option represents a functional option of a Client.
func WithDialer ¶
WithDialer sets the underlying gorilla/websocket.Dialer should one want to customize things like the handshake timeout or TLS configuration. If this is not set, it'll use the provided gorilla/websocket.DefaultDialer.
func WithEventSubscriptions ¶
WithEventSubscriptions specifies the events we'd like to subscribe to via Client.Listen. The value is a bitmask of any of the subscription values specified in subscriptions. By default, all event categories are subscribed, except for events marked as high volume. High volume events must be explicitly subscribed to.
func WithLogger ¶
WithLogger sets the logger this library will use. See the logger.Logger interface. Should be compatible with most third-party loggers.
func WithRequestHeader ¶
WithRequestHeader sets custom headers our client can send when trying to connect to the WebSockets server, allowing us specify the origin, subprotocols, or the user agent.
func WithResponseTimeout ¶
WithResponseTimeout sets the time we're willing to wait to receive a response from the server for any request, before responding with an error. It's in milliseconds. The default timeout is 10 seconds.