class Obsctl::OBS::Client

Overview

obs-websocket 5.x client used by the server-owned OBS supervisor.

Defined in:

obsctl/obs/client.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(config : Config::Config, event_subscriptions : Int32 | Nil = nil) #

[View source]

Instance Method Detail

def close : Nil #

Closes the WebSocket and marks this client as no longer identified.


[View source]
def connect : Nil #

Opens the WebSocket, performs Hello/Identify/Identified, and starts the reader fiber used for events and request responses.


[View source]
def connected? : Bool #

Returns true after Identify completes and the underlying socket is open.


[View source]
def current_scene : String | Nil #

Returns the current OBS program scene name when available.


[View source]
def events : Channel(Obsctl::OBS::Protocol::Event) #

Channel of parsed OBS events from opcode 5 frames.


[View source]
def input_muted(name : String) : Bool | Nil #

Returns mute state for an OBS input by exact OBS input name.


[View source]
def input_names : Array(String) #

Returns current OBS input names.


[View source]
def input_volume(name : String) : NamedTuple(mul: Float64 | Nil, db: Float64 | Nil, percent: Int32 | Nil) #

Returns OBS input volume in multiplier, dB, and user-facing percent.


[View source]
def mute(name : String, muted : Bool) : Nil #

Sets mute state for an OBS input by exact OBS input name.


[View source]
def request(request_type : String, data : JSON::Any | Nil = nil) : Protocol::Response #

Sends a typed obs-websocket request frame and waits for the matching request ID response or timeout.


[View source]
def scene_names : Array(String) #

Returns the current OBS scene names in OBS order.


[View source]
def set_scene(name : String) : Nil #

Changes the current OBS program scene by exact OBS scene name.


[View source]
def set_volume(name : String, percent : Int32) : Nil #

Sets OBS input volume using a user-facing 0-100 percentage.


[View source]
def snapshot : State::ObsSnapshot #

Fetches a full state snapshot for publication to local IPC clients.


[View source]
def terminal_error : Domain::ConnectionFailed | Nil #

Returns the safe terminal connection error that closed this client.


[View source]
def toggle_mute(name : String) : Nil #

Toggles mute state for an OBS input by exact OBS input name.


[View source]
def version : JSON::Any #

Fetches OBS and obs-websocket version metadata.


[View source]
def wait_for_close(timeout : Time::Span) : Domain::ConnectionFailed | Nil #

Waits for the WebSocket reader to observe a terminal close or protocol error, returning the same sanitized error exposed by #terminal_error.


[View source]