Skip to content

Commit 4e5003a

Browse files
committed
feat(codegen): refresh protocol from OBS WebSocket master
Regenerates all source files against the latest protocol.json, which adds Canvas lifecycle events (CanvasCreated, CanvasNameChanged, CanvasRemoved), a GetCanvasList response type, and optional canvasUuid filtering on scene-scoped requests. Updates ObsWebSocketClient.Helper to pass the new required GetSceneListRequestData argument.
1 parent 6266252 commit 4e5003a

54 files changed

Lines changed: 968 additions & 47 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

ObsWebSocket.Core/Generated/Client/ObsWebSocketClient.Events.g.cs

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,60 @@ namespace ObsWebSocket.Core;
1313
public sealed partial class ObsWebSocketClient
1414
{
1515

16+
/// <summary>
17+
/// Occurs when the <c>CanvasCreated</c> event is received from the OBS WebSocket server.
18+
/// </summary>
19+
/// <remarks>
20+
/// A new canvas has been created.
21+
/// <para>Requires the <c>Canvases</c> subscription.</para>
22+
/// <para>Category: canvases | Complexity: 2</para>
23+
/// <para>RPC Version: 1 | Initial Version: 5.7.0</para>
24+
/// </remarks>
25+
public event EventHandler<ObsWebSocket.Core.Events.Generated.CanvasCreatedEventArgs>? CanvasCreated;
26+
27+
/// <summary>Invokes the <see cref="CanvasCreated"/> event handler safely.</summary>
28+
/// <param name="e">The <see cref="ObsWebSocket.Core.Events.Generated.CanvasCreatedEventArgs"/> containing event data.</param>
29+
private void OnCanvasCreated(ObsWebSocket.Core.Events.Generated.CanvasCreatedEventArgs e)
30+
{
31+
CanvasCreated?.Invoke(this, e);
32+
}
33+
34+
/// <summary>
35+
/// Occurs when the <c>CanvasRemoved</c> event is received from the OBS WebSocket server.
36+
/// </summary>
37+
/// <remarks>
38+
/// A canvas has been removed.
39+
/// <para>Requires the <c>Canvases</c> subscription.</para>
40+
/// <para>Category: canvases | Complexity: 2</para>
41+
/// <para>RPC Version: 1 | Initial Version: 5.7.0</para>
42+
/// </remarks>
43+
public event EventHandler<ObsWebSocket.Core.Events.Generated.CanvasRemovedEventArgs>? CanvasRemoved;
44+
45+
/// <summary>Invokes the <see cref="CanvasRemoved"/> event handler safely.</summary>
46+
/// <param name="e">The <see cref="ObsWebSocket.Core.Events.Generated.CanvasRemovedEventArgs"/> containing event data.</param>
47+
private void OnCanvasRemoved(ObsWebSocket.Core.Events.Generated.CanvasRemovedEventArgs e)
48+
{
49+
CanvasRemoved?.Invoke(this, e);
50+
}
51+
52+
/// <summary>
53+
/// Occurs when the <c>CanvasNameChanged</c> event is received from the OBS WebSocket server.
54+
/// </summary>
55+
/// <remarks>
56+
/// The name of a canvas has changed.
57+
/// <para>Requires the <c>Canvases</c> subscription.</para>
58+
/// <para>Category: canvases | Complexity: 2</para>
59+
/// <para>RPC Version: 1 | Initial Version: 5.7.0</para>
60+
/// </remarks>
61+
public event EventHandler<ObsWebSocket.Core.Events.Generated.CanvasNameChangedEventArgs>? CanvasNameChanged;
62+
63+
/// <summary>Invokes the <see cref="CanvasNameChanged"/> event handler safely.</summary>
64+
/// <param name="e">The <see cref="ObsWebSocket.Core.Events.Generated.CanvasNameChangedEventArgs"/> containing event data.</param>
65+
private void OnCanvasNameChanged(ObsWebSocket.Core.Events.Generated.CanvasNameChangedEventArgs e)
66+
{
67+
CanvasNameChanged?.Invoke(this, e);
68+
}
69+
1670
/// <summary>
1771
/// Occurs when the <c>CurrentSceneCollectionChanging</c> event is received from the OBS WebSocket server.
1872
/// </summary>

ObsWebSocket.Core/Generated/Client/ObsWebSocketClient.Extensions.g.cs

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,25 @@ namespace ObsWebSocket.Core;
1919
/// </summary>
2020
public static partial class ObsWebSocketClientExtensions
2121
{
22+
/// <summary>
23+
/// Gets an array of canvases in OBS.
24+
/// </summary>
25+
/// <param name="client">The <see cref="ObsWebSocketClient"/> instance.</param>
26+
/// <param name="cancellationToken">A token to cancel the asynchronous operation.</param>
27+
/// <returns>A task representing the asynchronous operation. Yields the <see cref="ObsWebSocket.Core.Protocol.Responses.GetCanvasListResponseData"/> response data, or <c>null</c> if the successful response does not contain data.</returns>
28+
/// <remarks>
29+
/// <para>OBS WebSocket Protocol Category: canvases</para>
30+
/// <para>Complexity Rating: 3/5</para>
31+
/// <para>RPC Version: 1 | Initial OBS WebSocket Version: 5.7.0</para>
32+
/// Generated from obs-websocket protocol definition.</remarks>
33+
/// <exception cref="ObsWebSocketException">Thrown if the request fails on the OBS side.</exception>
34+
/// <exception cref="InvalidOperationException">Thrown if the client is not connected.</exception>
35+
/// <exception cref="OperationCanceledException">Thrown if cancelled.</exception>
36+
public static async Task<ObsWebSocket.Core.Protocol.Responses.GetCanvasListResponseData?> GetCanvasListAsync(this ObsWebSocketClient client, CancellationToken cancellationToken = default)
37+
{
38+
return await client.CallAsync<ObsWebSocket.Core.Protocol.Responses.GetCanvasListResponseData>("GetCanvasList", null, cancellationToken: cancellationToken).ConfigureAwait(false);
39+
}
40+
2241
/// <summary>
2342
/// Gets the value of a &quot;slot&quot; from the selected persistent data realm.
2443
/// </summary>
@@ -2318,9 +2337,10 @@ public static async Task SetSceneItemBlendModeAsync(this ObsWebSocketClient clie
23182337
}
23192338

23202339
/// <summary>
2321-
/// Gets an array of all scenes in OBS.
2340+
/// Gets an array of scenes in OBS.
23222341
/// </summary>
23232342
/// <param name="client">The <see cref="ObsWebSocketClient"/> instance.</param>
2343+
/// <param name="requestData">The data required for the request (<see cref="ObsWebSocket.Core.Protocol.Requests.GetSceneListRequestData"/>).</param>
23242344
/// <param name="cancellationToken">A token to cancel the asynchronous operation.</param>
23252345
/// <returns>A task representing the asynchronous operation. Yields the <see cref="ObsWebSocket.Core.Protocol.Responses.GetSceneListResponseData"/> response data, or <c>null</c> if the successful response does not contain data.</returns>
23262346
/// <remarks>
@@ -2331,9 +2351,9 @@ public static async Task SetSceneItemBlendModeAsync(this ObsWebSocketClient clie
23312351
/// <exception cref="ObsWebSocketException">Thrown if the request fails on the OBS side.</exception>
23322352
/// <exception cref="InvalidOperationException">Thrown if the client is not connected.</exception>
23332353
/// <exception cref="OperationCanceledException">Thrown if cancelled.</exception>
2334-
public static async Task<ObsWebSocket.Core.Protocol.Responses.GetSceneListResponseData?> GetSceneListAsync(this ObsWebSocketClient client, CancellationToken cancellationToken = default)
2354+
public static async Task<ObsWebSocket.Core.Protocol.Responses.GetSceneListResponseData?> GetSceneListAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.GetSceneListRequestData requestData, CancellationToken cancellationToken = default)
23352355
{
2336-
return await client.CallAsync<ObsWebSocket.Core.Protocol.Responses.GetSceneListResponseData>("GetSceneList", null, cancellationToken: cancellationToken).ConfigureAwait(false);
2356+
return await client.CallAsync<ObsWebSocket.Core.Protocol.Responses.GetSceneListResponseData>("GetSceneList", requestData, cancellationToken: cancellationToken).ConfigureAwait(false);
23372357
}
23382358

23392359
/// <summary>
@@ -2360,7 +2380,9 @@ public static async Task SetSceneItemBlendModeAsync(this ObsWebSocketClient clie
23602380
/// <summary>
23612381
/// Gets the current program scene.
23622382
///
2363-
/// Note: This request is slated to have the `currentProgram`-prefixed fields removed from in an upcoming RPC version.
2383+
/// Note 1: This request is slated to have the `currentProgram`-prefixed fields removed from in an upcoming RPC version.
2384+
///
2385+
/// Note 2: Canvases do not have any concept of a program or preview scene, so this request does not support canvases.
23642386
/// </summary>
23652387
/// <param name="client">The <see cref="ObsWebSocketClient"/> instance.</param>
23662388
/// <param name="cancellationToken">A token to cancel the asynchronous operation.</param>

ObsWebSocket.Core/Generated/Client/ObsWebSocketClient.WaitForEvent.g.cs

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,69 @@ public static partial class ObsWebSocketClientHelpers
6262
// This switch is generated based on known events with data from protocol.json
6363
switch (typeof(TEventArgs))
6464
{
65+
case Type t when t == typeof(ObsWebSocket.Core.Events.Generated.CanvasCreatedEventArgs):
66+
{
67+
EventHandler<ObsWebSocket.Core.Events.Generated.CanvasCreatedEventArgs> specificHandler = (sender, e) =>
68+
{
69+
try
70+
{
71+
if (predicate((TEventArgs)(object)e))
72+
{
73+
tcs.TrySetResult((TEventArgs?)(object?)e);
74+
}
75+
}
76+
catch (Exception ex)
77+
{
78+
// Catch exceptions from user predicate and fail the task
79+
tcs.TrySetException(ex);
80+
}
81+
};
82+
client.CanvasCreated += specificHandler;
83+
unsubscribeAction = () => client.CanvasCreated -= specificHandler;
84+
break;
85+
}
86+
case Type t when t == typeof(ObsWebSocket.Core.Events.Generated.CanvasRemovedEventArgs):
87+
{
88+
EventHandler<ObsWebSocket.Core.Events.Generated.CanvasRemovedEventArgs> specificHandler = (sender, e) =>
89+
{
90+
try
91+
{
92+
if (predicate((TEventArgs)(object)e))
93+
{
94+
tcs.TrySetResult((TEventArgs?)(object?)e);
95+
}
96+
}
97+
catch (Exception ex)
98+
{
99+
// Catch exceptions from user predicate and fail the task
100+
tcs.TrySetException(ex);
101+
}
102+
};
103+
client.CanvasRemoved += specificHandler;
104+
unsubscribeAction = () => client.CanvasRemoved -= specificHandler;
105+
break;
106+
}
107+
case Type t when t == typeof(ObsWebSocket.Core.Events.Generated.CanvasNameChangedEventArgs):
108+
{
109+
EventHandler<ObsWebSocket.Core.Events.Generated.CanvasNameChangedEventArgs> specificHandler = (sender, e) =>
110+
{
111+
try
112+
{
113+
if (predicate((TEventArgs)(object)e))
114+
{
115+
tcs.TrySetResult((TEventArgs?)(object?)e);
116+
}
117+
}
118+
catch (Exception ex)
119+
{
120+
// Catch exceptions from user predicate and fail the task
121+
tcs.TrySetException(ex);
122+
}
123+
};
124+
client.CanvasNameChanged += specificHandler;
125+
unsubscribeAction = () => client.CanvasNameChanged -= specificHandler;
126+
break;
127+
}
65128
case Type t when t == typeof(ObsWebSocket.Core.Events.Generated.CurrentSceneCollectionChangingEventArgs):
66129
{
67130
EventHandler<ObsWebSocket.Core.Events.Generated.CurrentSceneCollectionChangingEventArgs> specificHandler = (sender, e) =>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// <auto-generated/>
2+
#nullable enable
3+
4+
using ObsWebSocket.Core.Protocol.Events;
5+
using ObsWebSocket.Core.Events;
6+
7+
namespace ObsWebSocket.Core.Events.Generated;
8+
9+
/// <summary>
10+
/// Provides event data for the &lt;c&gt;CanvasCreated&lt;/c&gt; event.
11+
/// </summary>
12+
/// <remarks>
13+
/// A new canvas has been created.
14+
/// <para>Requires Subscription: Canvases | Complexity: 2</para>
15+
/// <para>RPC Version: 1 | Initial Version: 5.7.0</para>
16+
/// Generated from obs-websocket protocol definition.</remarks>
17+
/// <param name="payload">The strongly-typed data payload (<see cref="CanvasCreatedPayload"/>) for this event.</param>
18+
public sealed partial class CanvasCreatedEventArgs(CanvasCreatedPayload payload) : ObsEventEventArgs<ObsWebSocket.Core.Protocol.Events.CanvasCreatedPayload>(payload)
19+
{
20+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// <auto-generated/>
2+
#nullable enable
3+
4+
using ObsWebSocket.Core.Protocol.Events;
5+
using ObsWebSocket.Core.Events;
6+
7+
namespace ObsWebSocket.Core.Events.Generated;
8+
9+
/// <summary>
10+
/// Provides event data for the &lt;c&gt;CanvasNameChanged&lt;/c&gt; event.
11+
/// </summary>
12+
/// <remarks>
13+
/// The name of a canvas has changed.
14+
/// <para>Requires Subscription: Canvases | Complexity: 2</para>
15+
/// <para>RPC Version: 1 | Initial Version: 5.7.0</para>
16+
/// Generated from obs-websocket protocol definition.</remarks>
17+
/// <param name="payload">The strongly-typed data payload (<see cref="CanvasNameChangedPayload"/>) for this event.</param>
18+
public sealed partial class CanvasNameChangedEventArgs(CanvasNameChangedPayload payload) : ObsEventEventArgs<ObsWebSocket.Core.Protocol.Events.CanvasNameChangedPayload>(payload)
19+
{
20+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// <auto-generated/>
2+
#nullable enable
3+
4+
using ObsWebSocket.Core.Protocol.Events;
5+
using ObsWebSocket.Core.Events;
6+
7+
namespace ObsWebSocket.Core.Events.Generated;
8+
9+
/// <summary>
10+
/// Provides event data for the &lt;c&gt;CanvasRemoved&lt;/c&gt; event.
11+
/// </summary>
12+
/// <remarks>
13+
/// A canvas has been removed.
14+
/// <para>Requires Subscription: Canvases | Complexity: 2</para>
15+
/// <para>RPC Version: 1 | Initial Version: 5.7.0</para>
16+
/// Generated from obs-websocket protocol definition.</remarks>
17+
/// <param name="payload">The strongly-typed data payload (<see cref="CanvasRemovedPayload"/>) for this event.</param>
18+
public sealed partial class CanvasRemovedEventArgs(CanvasRemovedPayload payload) : ObsEventEventArgs<ObsWebSocket.Core.Protocol.Events.CanvasRemovedPayload>(payload)
19+
{
20+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// <auto-generated/>
2+
#nullable enable
3+
4+
using System;
5+
using System.Collections.Generic;
6+
using System.Text.Json;
7+
using System.Text.Json.Serialization;
8+
using System.Diagnostics.CodeAnalysis;
9+
using MessagePack;
10+
using ObsWebSocket.Core.Protocol.Common;
11+
using ObsWebSocket.Core.Protocol.Common.NestedTypes;
12+
13+
namespace ObsWebSocket.Core.Protocol.Events;
14+
15+
/// <summary>
16+
/// Data payload for the CanvasCreated event.
17+
/// </summary>
18+
/// <remarks>
19+
/// A new canvas has been created.
20+
/// <para>Requires Subscription: Canvases | Complexity: 2</para>
21+
/// <para>RPC Version: 1 | Initial Version: 5.7.0</para>
22+
/// Generated from obs-websocket protocol definition.</remarks>
23+
#pragma warning disable CS8618
24+
[MessagePackObject]
25+
public sealed partial record CanvasCreatedPayload
26+
{
27+
/// <summary>
28+
/// Name of the new canvas
29+
/// </summary>
30+
[JsonPropertyName("canvasName")]
31+
[Key("canvasName")]
32+
public string? CanvasName { get; init; }
33+
34+
/// <summary>
35+
/// UUID of the new canvas
36+
/// </summary>
37+
[JsonPropertyName("canvasUuid")]
38+
[Key("canvasUuid")]
39+
public string? CanvasUuid { get; init; }
40+
41+
/// <summary>Initializes a new instance for deserialization via <see cref="JsonConstructorAttribute"/>.</summary>
42+
[JsonConstructor]
43+
public CanvasCreatedPayload() { }
44+
45+
/// <summary>
46+
/// Initializes a new instance with all properties specified.
47+
/// <para>Parameters are ordered with required properties first, then optional properties (with defaults). Follows protocol definition order where possible.</para>
48+
/// </summary>
49+
public CanvasCreatedPayload(string? canvasName = null, string? canvasUuid = null)
50+
{
51+
this.CanvasName = canvasName;
52+
this.CanvasUuid = canvasUuid;
53+
}
54+
55+
}
56+
#pragma warning restore CS8618
57+
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
// <auto-generated/>
2+
#nullable enable
3+
4+
using System;
5+
using System.Collections.Generic;
6+
using System.Text.Json;
7+
using System.Text.Json.Serialization;
8+
using System.Diagnostics.CodeAnalysis;
9+
using MessagePack;
10+
using ObsWebSocket.Core.Protocol.Common;
11+
using ObsWebSocket.Core.Protocol.Common.NestedTypes;
12+
13+
namespace ObsWebSocket.Core.Protocol.Events;
14+
15+
/// <summary>
16+
/// Data payload for the CanvasNameChanged event.
17+
/// </summary>
18+
/// <remarks>
19+
/// The name of a canvas has changed.
20+
/// <para>Requires Subscription: Canvases | Complexity: 2</para>
21+
/// <para>RPC Version: 1 | Initial Version: 5.7.0</para>
22+
/// Generated from obs-websocket protocol definition.</remarks>
23+
#pragma warning disable CS8618
24+
[MessagePackObject]
25+
public sealed partial record CanvasNameChangedPayload
26+
{
27+
/// <summary>
28+
/// New name of the canvas
29+
/// </summary>
30+
[JsonPropertyName("canvasName")]
31+
[Key("canvasName")]
32+
public string? CanvasName { get; init; }
33+
34+
/// <summary>
35+
/// UUID of the canvas
36+
/// </summary>
37+
[JsonPropertyName("canvasUuid")]
38+
[Key("canvasUuid")]
39+
public string? CanvasUuid { get; init; }
40+
41+
/// <summary>
42+
/// Old name of the canvas
43+
/// </summary>
44+
[JsonPropertyName("oldCanvasName")]
45+
[Key("oldCanvasName")]
46+
public string? OldCanvasName { get; init; }
47+
48+
/// <summary>Initializes a new instance for deserialization via <see cref="JsonConstructorAttribute"/>.</summary>
49+
[JsonConstructor]
50+
public CanvasNameChangedPayload() { }
51+
52+
/// <summary>
53+
/// Initializes a new instance with all properties specified.
54+
/// <para>Parameters are ordered with required properties first, then optional properties (with defaults). Follows protocol definition order where possible.</para>
55+
/// </summary>
56+
public CanvasNameChangedPayload(string? canvasUuid = null, string? oldCanvasName = null, string? canvasName = null)
57+
{
58+
this.CanvasUuid = canvasUuid;
59+
this.OldCanvasName = oldCanvasName;
60+
this.CanvasName = canvasName;
61+
}
62+
63+
}
64+
#pragma warning restore CS8618
65+

0 commit comments

Comments
 (0)