-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32 from meenzen/feat/more-event-types
feat: support more event types
- Loading branch information
Showing
24 changed files
with
924 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Streamlabs.SocketClient.Extensions | ||
|
||
See [Streamlabs.SocketClient](https://www.nuget.org/packages/Streamlabs.SocketClient.Extensions) for more information. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/Streamlabs.SocketClient/Converters/IntStringConverter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using System.Globalization; | ||
using System.Text.Json; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Streamlabs.SocketClient.Converters; | ||
|
||
internal sealed class IntStringConverter : JsonConverter<int> | ||
{ | ||
public override int Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) | ||
{ | ||
return int.Parse( | ||
reader.GetString() ?? throw new InvalidOperationException("String is null"), | ||
NumberStyles.AllowThousands, | ||
CultureInfo.InvariantCulture | ||
); | ||
} | ||
|
||
public override void Write(Utf8JsonWriter writer, int value, JsonSerializerOptions options) | ||
{ | ||
writer.WriteStringValue(value.ToString()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using Streamlabs.SocketClient.Events.Abstractions; | ||
using Streamlabs.SocketClient.Messages; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Streamlabs.SocketClient.Events; | ||
|
||
public sealed record RaidEvent : IStreamlabsEvent, IHasStreamlabsMessageCollection<RaidMessage> | ||
{ | ||
[JsonPropertyName("message")] | ||
public required IReadOnlyCollection<RaidMessage> Messages { get; init; } | ||
|
||
[JsonPropertyName("for")] | ||
public required string For { get; init; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using Streamlabs.SocketClient.Events.Abstractions; | ||
using Streamlabs.SocketClient.Messages; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Streamlabs.SocketClient.Events; | ||
|
||
public sealed record RollEndCreditsEvent : IStreamlabsEvent, IHasStreamlabsMessage<RollEndCreditsMessage>, IHasEventId | ||
{ | ||
[JsonPropertyName("message")] | ||
public required RollEndCreditsMessage Message { get; init; } | ||
|
||
[JsonPropertyName("event_id")] | ||
public required string EventId { get; init; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using Streamlabs.SocketClient.Events.Abstractions; | ||
using Streamlabs.SocketClient.Messages; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Streamlabs.SocketClient.Events; | ||
|
||
public sealed record StreamlabelsEvent : IStreamlabsEvent, IHasStreamlabsMessage<StreamlabelsMessage>, IHasEventId | ||
{ | ||
[JsonPropertyName("message")] | ||
public required StreamlabelsMessage Message { get; init; } | ||
|
||
[JsonPropertyName("event_id")] | ||
public required string EventId { get; init; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
src/Streamlabs.SocketClient/Messages/DataTypes/LabeledCollection.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Streamlabs.SocketClient.Messages.DataTypes; | ||
|
||
public sealed record LabeledCollection<T> | ||
{ | ||
[JsonPropertyName("label")] | ||
public required string Label { get; init; } | ||
|
||
[JsonPropertyName("values")] | ||
public required IReadOnlyCollection<T> Values { get; init; } | ||
} |
53 changes: 53 additions & 0 deletions
53
src/Streamlabs.SocketClient/Messages/DataTypes/RollEndCreditsPayload.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
using Streamlabs.SocketClient.Messages.Abstractions; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Streamlabs.SocketClient.Messages.DataTypes; | ||
|
||
public sealed record RollEndCreditsPayload : IHasMessageId, IHasPriority | ||
{ | ||
/// <summary> | ||
/// A list of users that donated | ||
/// </summary> | ||
[JsonPropertyName("donations")] | ||
public LabeledCollection<string>? Donations { get; init; } | ||
|
||
/// <summary> | ||
/// A list of users that used bits | ||
/// </summary> | ||
[JsonPropertyName("bits")] | ||
public LabeledCollection<string>? Bits { get; init; } | ||
|
||
/// <summary> | ||
/// A list of users that are moderators | ||
/// </summary> | ||
[JsonPropertyName("moderators")] | ||
public LabeledCollection<string>? Moderators { get; init; } | ||
|
||
/// <summary> | ||
/// A list of users that followed | ||
/// </summary> | ||
[JsonPropertyName("followers")] | ||
public LabeledCollection<string>? Followers { get; init; } | ||
|
||
/// <summary> | ||
/// A list of users that subscribed or resubscribed | ||
/// </summary> | ||
[JsonPropertyName("subscribers")] | ||
public LabeledCollection<string>? Subscribers { get; init; } | ||
|
||
/// <summary> | ||
/// A list of channels that raided | ||
/// </summary> | ||
public LabeledCollection<string>? Raids { get; init; } | ||
|
||
/// <summary> | ||
/// A list of channels that hosted | ||
/// </summary> | ||
public LabeledCollection<string>? Hosts { get; init; } | ||
|
||
[JsonPropertyName("_id")] | ||
public required string MessageId { get; init; } | ||
|
||
[JsonPropertyName("priority")] | ||
public required long Priority { get; init; } | ||
} |
121 changes: 121 additions & 0 deletions
121
src/Streamlabs.SocketClient/Messages/DataTypes/RollEndCreditsSettings.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
using Streamlabs.SocketClient.Messages.Abstractions; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Streamlabs.SocketClient.Messages.DataTypes; | ||
|
||
public sealed record RollEndCreditsSettings : IHasMessageId, IHasPriority | ||
{ | ||
[JsonPropertyName("theme")] | ||
public required string Theme { get; init; } | ||
|
||
[JsonPropertyName("donations")] | ||
public required bool Donations { get; init; } | ||
|
||
[JsonPropertyName("credit_title")] | ||
public required string CreditTitle { get; init; } | ||
|
||
[JsonPropertyName("credit_subtitle")] | ||
public required string CreditSubTitle { get; init; } | ||
|
||
[JsonPropertyName("donor_change")] | ||
public required string DonorChange { get; init; } | ||
|
||
[JsonPropertyName("loop_credits")] | ||
public required bool LoopCredits { get; init; } | ||
|
||
[JsonPropertyName("delay_time")] | ||
public required int DelayTime { get; init; } | ||
|
||
[JsonPropertyName("roll_speed")] | ||
public required int RollSpeed { get; init; } | ||
|
||
/// <summary> | ||
/// The background color (hex) | ||
/// </summary> | ||
[JsonPropertyName("background_color")] | ||
public required string BackgroundColor { get; init; } | ||
|
||
[JsonPropertyName("font")] | ||
public required string Font { get; init; } | ||
|
||
/// <summary> | ||
/// The font color (hex) | ||
/// </summary> | ||
[JsonPropertyName("font_color")] | ||
public required string FontColor { get; init; } | ||
|
||
[JsonPropertyName("font_size")] | ||
public required int FontSize { get; init; } | ||
|
||
[JsonPropertyName("roll_time")] | ||
public required int RollTime { get; init; } | ||
|
||
[JsonPropertyName("roll_options")] | ||
public required string RollOptions { get; init; } | ||
|
||
[JsonPropertyName("custom_enabled")] | ||
public required bool CustomEnabled { get; init; } | ||
|
||
[JsonPropertyName("custom_html")] | ||
public required string CustomHtml { get; init; } | ||
|
||
[JsonPropertyName("custom_css")] | ||
public required string CustomCss { get; init; } | ||
|
||
[JsonPropertyName("custom_js")] | ||
public required string CustomJs { get; init; } | ||
|
||
[JsonPropertyName("custom_json")] | ||
public required string? CustomJson { get; init; } | ||
|
||
[JsonPropertyName("show_amounts")] | ||
public required bool ShowAmounts { get; init; } | ||
|
||
[JsonPropertyName("roll_credits_on_load")] | ||
public required bool RollCreditsOnLoad { get; init; } | ||
|
||
[JsonPropertyName("followers")] | ||
public required bool Followers { get; init; } | ||
|
||
[JsonPropertyName("subscribers")] | ||
public required bool Subscribers { get; init; } | ||
|
||
[JsonPropertyName("bits")] | ||
public required bool Bits { get; init; } | ||
|
||
[JsonPropertyName("moderators")] | ||
public required bool Moderators { get; init; } | ||
|
||
[JsonPropertyName("raids")] | ||
public required bool Raids { get; init; } | ||
|
||
[JsonPropertyName("hosts")] | ||
public required bool Hosts { get; init; } | ||
|
||
[JsonPropertyName("followers_change")] | ||
public required string FollowersChange { get; init; } | ||
|
||
/// <summary> | ||
/// This property is HTML encoded | ||
/// </summary> | ||
[JsonPropertyName("subscribers_change")] | ||
public required string SubscribersChange { get; init; } | ||
|
||
[JsonPropertyName("bits_change")] | ||
public required string BitsChange { get; init; } | ||
|
||
[JsonPropertyName("mods_change")] | ||
public required string ModsChange { get; init; } | ||
|
||
[JsonPropertyName("raids_change")] | ||
public required string RaidsChange { get; init; } | ||
|
||
[JsonPropertyName("hosts_change")] | ||
public required string HostsChange { get; init; } | ||
|
||
[JsonPropertyName("_id")] | ||
public required string MessageId { get; init; } | ||
|
||
[JsonPropertyName("priority")] | ||
public required long Priority { get; init; } | ||
} |
Oops, something went wrong.