diff --git a/TwitchLib.EventSub.Core/AsyncEventHandler.cs b/TwitchLib.EventSub.Core/AsyncEventHandler.cs new file mode 100644 index 0000000..c500843 --- /dev/null +++ b/TwitchLib.EventSub.Core/AsyncEventHandler.cs @@ -0,0 +1,18 @@ +using System; +using System.Threading.Tasks; + +namespace TwitchLib.EventSub.Core +{ + /// + /// Custom implementation of asynchronous event handler + /// This is useful to properly and safely handle async Tasks + /// Reference: https://medium.com/@a.lyskawa/the-hitchhiker-guide-to-asynchronous-events-in-c-e9840109fb53 + /// + public delegate Task AsyncEventHandler(object sender, TEventArgs args); + /// + /// Custom implementation of asynchronous event handler + /// This is useful to properly and safely handle async Tasks + /// Reference: https://medium.com/@a.lyskawa/the-hitchhiker-guide-to-asynchronous-events-in-c-e9840109fb53 + /// + public delegate Task AsyncEventHandler(object sender, EventArgs args); +} \ No newline at end of file diff --git a/TwitchLib.EventSub.Core/Extensions/AsyncEventHandlerExtensions.cs b/TwitchLib.EventSub.Core/Extensions/AsyncEventHandlerExtensions.cs new file mode 100644 index 0000000..cdd345d --- /dev/null +++ b/TwitchLib.EventSub.Core/Extensions/AsyncEventHandlerExtensions.cs @@ -0,0 +1,18 @@ +using System; +using System.Threading.Tasks; + +namespace TwitchLib.EventSub.Core.Extensions +{ + public static class AsyncEventHandlerExtensions + { + public static Task InvokeAsync(this AsyncEventHandler asyncEventHandler, object sender, TEventArgs args) + { + return asyncEventHandler != null ? asyncEventHandler(sender, args) : Task.CompletedTask; + } + + public static Task InvokeAsync(this AsyncEventHandler asyncEventHandler, object sender, EventArgs args) + { + return asyncEventHandler != null ? asyncEventHandler(sender, args) : Task.CompletedTask; + } + } +} \ No newline at end of file diff --git a/TwitchLib.EventSub.Core/Models/GuestStar/ChannelGuestStarBase.cs b/TwitchLib.EventSub.Core/Models/GuestStar/ChannelGuestStarBase.cs new file mode 100644 index 0000000..501b018 --- /dev/null +++ b/TwitchLib.EventSub.Core/Models/GuestStar/ChannelGuestStarBase.cs @@ -0,0 +1,51 @@ +namespace TwitchLib.EventSub.Core.Models.GuestStar +{ + public abstract class ChannelGuestStarBase + { + /// + /// The broadcaster user ID + /// + public string BroadcasterUserId { get; set; } = string.Empty; + /// + /// The broadcaster display name + /// + public string BroadcasterUserName { get; set; } = string.Empty; + /// + /// The broadcaster login + /// + public string BroadcasterUserLogin { get; set; } = string.Empty; + /// + /// Unique ID representing the session. + /// + public string SessionId { get; set; } = string.Empty; + /// + /// The moderator user ID + /// + public string ModeratorUserId { get; set; } = string.Empty; + /// + /// The moderator display name + /// + public string ModeratorUserName { get; set; } = string.Empty; + /// + /// The moderator login + /// + public string ModeratorUserLogin { get; set; } = string.Empty; + /// + /// The user ID of the guest + /// + public string GuestStarUserId { get; set; } = string.Empty; + /// + /// The guest display name + /// + public string GuestStarUserName { get; set; } = string.Empty; + /// + /// The guest login + /// + public string GuestStarUserLogin { get; set; } = string.Empty; + /// + /// The ID of the slot assignment the guest is assigned to. null/empty if the guest is in the INVITED state. + /// or the ID of the slot where settings were updated. + /// + public string SlotId { get; set; } = string.Empty; + } +} \ No newline at end of file diff --git a/TwitchLib.EventSub.Core/Models/GuestStar/ChannelGuestStarSessionBase.cs b/TwitchLib.EventSub.Core/Models/GuestStar/ChannelGuestStarSessionBase.cs new file mode 100644 index 0000000..7acb074 --- /dev/null +++ b/TwitchLib.EventSub.Core/Models/GuestStar/ChannelGuestStarSessionBase.cs @@ -0,0 +1,24 @@ +using System; + +namespace TwitchLib.EventSub.Core.Models.GuestStar +{ + public abstract class ChannelGuestStarSessionBase + { + /// + /// The broadcaster user ID + /// + public string BroadcasterUserId { get; set; } = string.Empty; + /// + /// The broadcaster display name + /// + public string BroadcasterUserName { get; set; } = string.Empty; + /// + /// The broadcaster login + /// + public string BroadcasterUserLogin { get; set; } = string.Empty; + /// + /// Unique ID representing the session. + /// + public string SessionId { get; set; } = string.Empty; + } +} \ No newline at end of file diff --git a/TwitchLib.EventSub.Core/SubscriptionTypes/Channel/ChannelGuestStarGuestUpdate.cs b/TwitchLib.EventSub.Core/SubscriptionTypes/Channel/ChannelGuestStarGuestUpdate.cs new file mode 100644 index 0000000..c4b0997 --- /dev/null +++ b/TwitchLib.EventSub.Core/SubscriptionTypes/Channel/ChannelGuestStarGuestUpdate.cs @@ -0,0 +1,32 @@ +using TwitchLib.EventSub.Core.Models.GuestStar; + +namespace TwitchLib.EventSub.Core.SubscriptionTypes.Channel +{ + /// + /// Channel GuestStar Guest Update subscription type model + /// Description: + /// The channel.guest_star_guest.update subscription type sends a notification when a guest moves between interaction states in an active Guest Star session. + /// + public class ChannelGuestStarGuestUpdate : ChannelGuestStarBase + { + /// + /// The current state of the user after the update has taken place. Can be one of the following: + /// + /// invited — The guest has transitioned to the invite queue. This can take place when the guest was previously assigned a slot, but have been removed from the call and are sent back to the invite queue. + /// + /// + /// ready — The guest has signaled they are ready and can be assigned a slot. + /// + /// + /// backstage — The guest has been assigned a slot in the session, but is not currently seen live in the broadcasting software. + /// + /// + /// live — The guest is now live in the host's broadcasting software. + /// + /// + /// removed — The guest was removed from the call or queue. + /// + /// + public string State { get; set; } = string.Empty; + } +} \ No newline at end of file diff --git a/TwitchLib.EventSub.Core/SubscriptionTypes/Channel/ChannelGuestStarSessionBegin.cs b/TwitchLib.EventSub.Core/SubscriptionTypes/Channel/ChannelGuestStarSessionBegin.cs new file mode 100644 index 0000000..8cb241f --- /dev/null +++ b/TwitchLib.EventSub.Core/SubscriptionTypes/Channel/ChannelGuestStarSessionBegin.cs @@ -0,0 +1,18 @@ +using System; +using TwitchLib.EventSub.Core.Models.GuestStar; + +namespace TwitchLib.EventSub.Core.SubscriptionTypes.Channel +{ + /// + /// Channel GuestStar Session Begin subscription type model + /// Description: + /// The channel.guest_star_session.begin subscription type sends a notification when the host begins a new Guest Star session. + /// + public class ChannelGuestStarSessionBegin : ChannelGuestStarSessionBase + { + /// + /// RFC3339 timestamp indicating the time the session began. + /// + public DateTimeOffset StartedAt { get; set; } + } +} \ No newline at end of file diff --git a/TwitchLib.EventSub.Core/SubscriptionTypes/Channel/ChannelGuestStarSessionEnd.cs b/TwitchLib.EventSub.Core/SubscriptionTypes/Channel/ChannelGuestStarSessionEnd.cs new file mode 100644 index 0000000..6028b16 --- /dev/null +++ b/TwitchLib.EventSub.Core/SubscriptionTypes/Channel/ChannelGuestStarSessionEnd.cs @@ -0,0 +1,22 @@ +using System; +using TwitchLib.EventSub.Core.Models.GuestStar; + +namespace TwitchLib.EventSub.Core.SubscriptionTypes.Channel +{ + /// + /// Channel GuestStar Session End subscription type model + /// Description: + /// The channel.guest_star_session.end subscription type sends a notification when a running Guest Star session is ended by the host, or automatically by the system. + /// + public class ChannelGuestStarSessionEnd : ChannelGuestStarSessionBase + { + /// + /// RFC3339 timestamp indicating the time the session began. + /// + public DateTimeOffset StartedAt { get; set; } + /// + /// RFC3339 timestamp indicating the time the session ended. + /// + public DateTimeOffset EndedAt { get; set; } + } +} \ No newline at end of file diff --git a/TwitchLib.EventSub.Core/SubscriptionTypes/Channel/ChannelGuestStarSettingsUpdate.cs b/TwitchLib.EventSub.Core/SubscriptionTypes/Channel/ChannelGuestStarSettingsUpdate.cs new file mode 100644 index 0000000..be25a9f --- /dev/null +++ b/TwitchLib.EventSub.Core/SubscriptionTypes/Channel/ChannelGuestStarSettingsUpdate.cs @@ -0,0 +1,41 @@ +namespace TwitchLib.EventSub.Core.SubscriptionTypes.Channel +{ + /// + /// Channel GuestStar Settings Update subscription type model + /// Description: + /// The channel.guest_star_settings.update subscription type sends a notification when the host preferences for Guest Star have been updated. + /// + public class ChannelGuestStarSettingsUpdate + { + /// + /// User ID of the host channel + /// + public string BroadcasterUserId { get; set; } = string.Empty; + /// + /// The broadcaster display name + /// + public string BroadcasterUserName { get; set; } = string.Empty; + /// + /// the broadcaster login + /// + public string BroadcasterUserLogin { get; set; } = string.Empty; + /// + /// Flag determining if Guest Star moderators have access to control whether a guest is live once assigned to a slot. + /// + public bool IsModeratorSendLiveEnabled { get; set; } + /// + /// Number of slots the Guest Star call interface will allow the host to add to a call. + /// + public int SlotCount { get; set; } + /// + /// Flag determining if browser sources subscribed to sessions on this channel should output audio + /// + public bool IsBrowserSourceAudioEnabled { get; set; } + /// + /// This setting determines how the guests within a session should be laid out within a group browser source. Can be one of the following values: + /// tiled — All live guests are tiled within the browser source with the same size. + /// screenshare — All live guests are tiled within the browser source with the same size. If there is an active screen share, it is sized larger than the other guests. + /// + public string GroupLayout { get; set; } = string.Empty; + } +} \ No newline at end of file diff --git a/TwitchLib.EventSub.Core/SubscriptionTypes/Channel/ChannelGuestStarSlotUpdate.cs b/TwitchLib.EventSub.Core/SubscriptionTypes/Channel/ChannelGuestStarSlotUpdate.cs new file mode 100644 index 0000000..086e15d --- /dev/null +++ b/TwitchLib.EventSub.Core/SubscriptionTypes/Channel/ChannelGuestStarSlotUpdate.cs @@ -0,0 +1,25 @@ +using TwitchLib.EventSub.Core.Models.GuestStar; + +namespace TwitchLib.EventSub.Core.SubscriptionTypes.Channel +{ + /// + /// Channel GuestStar Slot Update subscription type model + /// Description: + /// The channel.guest_star_slot.update subscription type sends a notification when a slot setting is updated in an active Guest Star session. + /// + public class ChannelGuestStarSlotUpdate : ChannelGuestStarBase + { + /// + /// Flag that signals whether the host is allowing the slot’s video to be seen by participants within the session. + /// + public bool HostVideoEnabled { get; set; } + /// + /// Flag that signals whether the host is allowing the slot’s audio to be heard by participants within the session. + /// + public bool HostAudioEnabled { get; set; } + /// + /// Value between 0-100 that represents the slot’s audio level as heard by participants within the session. + /// + public int HostVolume { get; set; } + } +} \ No newline at end of file diff --git a/TwitchLib.EventSub.Core/SubscriptionTypes/Channel/HypeTrainProgress.cs b/TwitchLib.EventSub.Core/SubscriptionTypes/Channel/HypeTrainProgress.cs index 209c21c..4e30021 100644 --- a/TwitchLib.EventSub.Core/SubscriptionTypes/Channel/HypeTrainProgress.cs +++ b/TwitchLib.EventSub.Core/SubscriptionTypes/Channel/HypeTrainProgress.cs @@ -21,7 +21,7 @@ public class HypeTrainProgress : HypeTrainBase /// /// The most recent contribution. /// - public HypeTrainContribution[] LastContribution { get; set; } = Array.Empty(); + public HypeTrainContribution LastContribution { get; set; } = new HypeTrainContribution(); /// /// The time when the Hype Train expires. The expiration is extended when the Hype Train reaches a new level. /// diff --git a/TwitchLib.EventSub.Core/TwitchLib.EventSub.Core.csproj b/TwitchLib.EventSub.Core/TwitchLib.EventSub.Core.csproj index 066361a..e4030d5 100644 --- a/TwitchLib.EventSub.Core/TwitchLib.EventSub.Core.csproj +++ b/TwitchLib.EventSub.Core/TwitchLib.EventSub.Core.csproj @@ -5,11 +5,10 @@ TwitchLib.EventSub.Core TwitchLib.EventSub.Core swiftyspiffy, Prom3theu5, Syzuna, LuckyNoS7evin - - 2.3.1 + 2.4.3 $(VersionSuffix) - 2.3.1 - 2.3.1 + 2.4.3 + 2.4.3 Contains Subscription Types and Models for Twitch's EventSub system https://cdn.syzuna-programs.de/images/twitchlib.png https://github.com/TwitchLib/TwitchLib.EventSub.Websockets @@ -18,7 +17,7 @@ MIT Copyright 2023 twitch library events eventsub subscriptiontypes c# csharp net netstandard2.0 netstandard2.1 5.0 6.0 7.0 - Added missing WinningOutcomeId to ChannelPredictionEnd model + Added GuestStar Subscription Types, added AsyncEventHandler delegate README.md en-US True