Skip to content

Typed access to free-form protocol fields - #47

Merged
Agash merged 2 commits into
masterfrom
feat/typed-free-form-fields
Sep 23, 2026
Merged

Agash merged 2 commits into
masterfrom
feat/typed-free-form-fields

Conversation

@Agash

@Agash Agash commented Sep 23, 2026

Copy link
Copy Markdown
Owner

Every field the protocol declares as free-form now has typed access, in both directions.

Reading: generated

The generator emits a pair of typed readers for each free-form field on an event payload or response. That is 17 fields, among them the settings carried by InputCreated, InputSettingsChanged, SourceFilterCreated and SourceFilterSettingsChanged, persistent data, vendor responses, and custom and vendor event data.

BrowserSourceSettings? browser = e.EventData.GetInputSettings<BrowserSourceSettings>();
OverlayCue? cue = e.EventData.GetEventData(MyContext.Default.OverlayCue);

One overload is for library-registered types, the other takes your JsonTypeInfo. A reader returns null when OBS sent nothing and throws ObsWebSocketSerializationException on a different shape. A test fails if any free-form property is missing its readers.

Writing: helpers

  • Config.GetPersistentDataAsync<T> / SetPersistentDataAsync<T>
  • General.CallVendorRequestAsync<TRequest, TResponse>
  • General.BroadcastCustomEventAsync<T>

Fixed

  • The output, stream service and transition settings setters let a raw JsonException escape when serialization failed, although their docs promise ObsWebSocketException. Every settings setter now throws ObsWebSocketSerializationException.
  • Generated sources were written with mixed line endings on Windows, so one file showed as changed after every regeneration. Each file now uses a single newline.

Checked, not changed

OBS treats a null slotValue as missing, so a persistent data slot cannot be cleared, only overwritten. SetPersistentDataAsync documents this.

@Agash
Agash merged commit 51d8a4a into master Sep 23, 2026
10 checks passed
@Agash
Agash deleted the feat/typed-free-form-fields branch September 23, 2026 04:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant