class

Obsctl::Server::StateStore

Inherits Reference < Object

Authoritative OBS snapshot cache owned by the local daemon.

Constructors

new(on_update : Proc(JSON::Any, Nil) | Nil = nil)

Creates a disconnected state store with an optional update callback.

Source

Class methods

snapshot_to_json(snapshot : OBS::State::ObsSnapshot) : JSON::Any

Converts a snapshot into the stable IPC state-event JSON shape.

Source

Instance methods

mark_connected(snapshot : OBS::State::ObsSnapshot, at : Time = Time.utc) : Nil

Records a successful OBS connection and publishes its fresh snapshot.

Source
mark_disconnected(error : String | Nil = nil, reconnecting : Bool = false, at : Time = Time.utc, connection_failed : Bool = true) : Nil

Marks OBS unavailable while preserving the last known lists and versions.

Source
mark_reconnect_attempt(at : Time = Time.utc) : Nil

Records that the supervisor is attempting to establish an OBS session.

Source
mark_reconnect_requested(at : Time = Time.utc) : Nil

Records a public operator reconnect request without treating it as an OBS connection failure.

Source
mark_reconnect_requested_and_build_payload(at : Time = Time.utc) : JSON::Any

Mutates authoritative reconnect state for a public operator reconnect request and returns the precomputed state-event payload so callers can defer subscriber fanout until their own locks are released.

Source
publish_snapshot_payload(payload : JSON::Any) : Nil

Publishes a precomputed state-event payload to subscribers.

Source
snapshot

Returns the latest cached OBS snapshot.

Source
snapshot_json

Returns the latest snapshot as the IPC state-event JSON payload.

Source
telemetry

Returns the current daemon-side OBS connection telemetry.

Source
update(snapshot : OBS::State::ObsSnapshot) : Nil

Replaces the cached snapshot and publishes it to subscribers.

Source
update_audio_inputs(audio_inputs : Array(OBS::State::AudioState)) : Nil

Replaces the audio input list in the cached snapshot and publishes.

Source
update_current_scene(scene_name : String) : Nil

Updates the current program scene without a full snapshot refetch.

Source
update_input_mute(input_name : String, muted : Bool) : Nil

Updates one audio input's mute state without a full snapshot refetch.

Source
update_input_volume(input_name : String, volume_mul : Float64 | Nil, volume_db : Float64 | Nil) : Nil

Updates one audio input's volume without a full snapshot refetch.

Source
update_output(streaming : Bool | Nil = nil, recording : Bool | Nil = nil) : Nil
Source
update_scenes(current_scene : String | Nil, scenes : Array(OBS::State::SceneState)) : Nil

Replaces the scene list in the cached snapshot and publishes.

Source
update_stats(stats : OBS::State::ObsStats, stream_bitrate_kbps : Float64 | Nil, stream_duration_ms : Int64 | Nil, record_duration_ms : Int64 | Nil, streaming : Bool | Nil = nil, recording : Bool | Nil = nil) : Nil

Updates periodically polled performance and output telemetry while preserving authoritative scene, audio, and profile state.

streaming/recording are the poll's view of output state. They are accepted here so a stream or recording toggled outside obsctl converges even if its StreamStateChanged event never arrives; nil leaves the cached value alone.

Source