From 58ed50c9d01c4e4e2c38d62025e1820e43b538d3 Mon Sep 17 00:00:00 2001 From: ipitio <21136719+ipitio@users.noreply.github.com> Date: Wed, 15 Feb 2023 21:58:49 -0500 Subject: Catch Exception when disposing connection --- MediaBrowser.Controller/Net/BasePeriodicWebSocketListener.cs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'MediaBrowser.Controller/Net') diff --git a/MediaBrowser.Controller/Net/BasePeriodicWebSocketListener.cs b/MediaBrowser.Controller/Net/BasePeriodicWebSocketListener.cs index fc9ea37d1e..48ee78a7cc 100644 --- a/MediaBrowser.Controller/Net/BasePeriodicWebSocketListener.cs +++ b/MediaBrowser.Controller/Net/BasePeriodicWebSocketListener.cs @@ -232,6 +232,11 @@ namespace MediaBrowser.Controller.Net // TODO Investigate and properly fix. Logger.LogError(ex, "Object Disposed"); } + catch (Exception ex) + { + // TODO Investigate and properly fix. + Logger.LogError(ex, "Object Disposed Exception"); + } lock (_activeConnections) { -- cgit v1.2.3 From c29e8ffe1d1ffe99c895ad228b6cfc5c18fb3b98 Mon Sep 17 00:00:00 2001 From: ipitio <21136719+ipitio@users.noreply.github.com> Date: Fri, 24 Feb 2023 11:45:56 -0500 Subject: Update MediaBrowser.Controller/Net/BasePeriodicWebSocketListener.cs Co-authored-by: Cody Robibero --- MediaBrowser.Controller/Net/BasePeriodicWebSocketListener.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'MediaBrowser.Controller/Net') diff --git a/MediaBrowser.Controller/Net/BasePeriodicWebSocketListener.cs b/MediaBrowser.Controller/Net/BasePeriodicWebSocketListener.cs index 48ee78a7cc..0524999c79 100644 --- a/MediaBrowser.Controller/Net/BasePeriodicWebSocketListener.cs +++ b/MediaBrowser.Controller/Net/BasePeriodicWebSocketListener.cs @@ -235,7 +235,7 @@ namespace MediaBrowser.Controller.Net catch (Exception ex) { // TODO Investigate and properly fix. - Logger.LogError(ex, "Object Disposed Exception"); + Logger.LogError(ex, "Error disposing websocket"); } lock (_activeConnections) -- cgit v1.2.3 From 9a0dfc00f1e36092476f62984ba66886032f4f89 Mon Sep 17 00:00:00 2001 From: Cody Robibero Date: Sat, 10 Jun 2023 07:28:21 -0600 Subject: Add all websocket messages to generated openapi spec (#9682) * Add all websocket messages to generated openapi spec * Use oneOf * JsonIgnore ServerId * Oops * Add discriminators * Add WebSocketMessage container for Inbound and Outbound messages --- Jellyfin.Server/Filters/AdditionalModelFilter.cs | 148 +++++++++++++++++++-- MediaBrowser.Controller/Net/WebSocketMessage.cs | 28 ++++ MediaBrowser.Controller/Net/WebSocketMessageOfT.cs | 33 +++++ .../WebSocketMessages/IInboundWebSocketMessage.cs | 10 ++ .../WebSocketMessages/IOutboundWebSocketMessage.cs | 10 ++ .../Inbound/ActivityLogEntryStartMessage.cs | 25 ++++ .../Inbound/ActivityLogEntryStopMessage.cs | 25 ++++ .../Inbound/ScheduledTasksInfoStartMessage.cs | 25 ++++ .../Inbound/ScheduledTasksInfoStopMessage.cs | 25 ++++ .../Inbound/SessionsStartMessage.cs | 24 ++++ .../Inbound/SessionsStopMessage.cs | 24 ++++ .../WebSocketMessages/InboundWebSocketMessage.cs | 9 ++ .../Outbound/ActivityLogEntryMessage.cs | 25 ++++ .../Outbound/ForceKeepAliveMessage.cs | 23 ++++ .../Outbound/GeneralCommandMessage.cs | 23 ++++ .../Outbound/LibraryChangedMessage.cs | 24 ++++ .../Net/WebSocketMessages/Outbound/PlayMessage.cs | 23 ++++ .../WebSocketMessages/Outbound/PlaystateMessage.cs | 23 ++++ .../Outbound/PluginInstallationCancelledMessage.cs | 24 ++++ .../Outbound/PluginInstallationCompletedMessage.cs | 24 ++++ .../Outbound/PluginInstallationFailedMessage.cs | 24 ++++ .../Outbound/PluginInstallingMessage.cs | 24 ++++ .../Outbound/PluginUninstalledMessage.cs | 24 ++++ .../Outbound/RefreshProgressMessage.cs | 24 ++++ .../Outbound/RestartRequiredMessage.cs | 14 ++ .../Outbound/ScheduledTaskEndedMessage.cs | 24 ++++ .../Outbound/ScheduledTasksInfoMessage.cs | 25 ++++ .../Outbound/SeriesTimerCancelledMessage.cs | 24 ++++ .../Outbound/SeriesTimerCreatedMessage.cs | 24 ++++ .../Outbound/ServerRestartingMessage.cs | 14 ++ .../Outbound/ServerShuttingDownMessage.cs | 14 ++ .../WebSocketMessages/Outbound/SessionsMessage.cs | 24 ++++ .../Outbound/SyncPlayCommandMessage.cs | 24 ++++ .../Outbound/SyncPlayGroupUpdateCommandMessage.cs | 24 ++++ ...SyncPlayGroupUpdateCommandOfGroupInfoMessage.cs | 25 ++++ ...yGroupUpdateCommandOfGroupStateUpdateMessage.cs | 25 ++++ ...ayGroupUpdateCommandOfPlayQueueUpdateMessage.cs | 25 ++++ .../SyncPlayGroupUpdateCommandOfStringMessage.cs | 25 ++++ .../Outbound/TimerCancelledMessage.cs | 24 ++++ .../Outbound/TimerCreatedMessage.cs | 24 ++++ .../Outbound/UserDataChangedMessage.cs | 23 ++++ .../Outbound/UserDeletedMessage.cs | 24 ++++ .../Outbound/UserUpdatedMessage.cs | 24 ++++ .../WebSocketMessages/OutboundWebSocketMessage.cs | 9 ++ .../WebSocketMessages/Shared/KeepAliveMessage.cs | 23 ++++ .../SyncPlay/Queue/PlayQueueManager.cs | 24 ++-- MediaBrowser.Model/Net/WebSocketMessage.cs | 31 ----- MediaBrowser.Model/SyncPlay/GroupUpdate.cs | 54 +++----- MediaBrowser.Model/SyncPlay/GroupUpdateOfT.cs | 31 +++++ MediaBrowser.Model/SyncPlay/PlayQueueUpdate.cs | 4 +- MediaBrowser.Model/SyncPlay/QueueItem.cs | 31 ----- MediaBrowser.Model/SyncPlay/SyncPlayQueueItem.cs | 31 +++++ 52 files changed, 1220 insertions(+), 119 deletions(-) create mode 100644 MediaBrowser.Controller/Net/WebSocketMessage.cs create mode 100644 MediaBrowser.Controller/Net/WebSocketMessageOfT.cs create mode 100644 MediaBrowser.Controller/Net/WebSocketMessages/IInboundWebSocketMessage.cs create mode 100644 MediaBrowser.Controller/Net/WebSocketMessages/IOutboundWebSocketMessage.cs create mode 100644 MediaBrowser.Controller/Net/WebSocketMessages/Inbound/ActivityLogEntryStartMessage.cs create mode 100644 MediaBrowser.Controller/Net/WebSocketMessages/Inbound/ActivityLogEntryStopMessage.cs create mode 100644 MediaBrowser.Controller/Net/WebSocketMessages/Inbound/ScheduledTasksInfoStartMessage.cs create mode 100644 MediaBrowser.Controller/Net/WebSocketMessages/Inbound/ScheduledTasksInfoStopMessage.cs create mode 100644 MediaBrowser.Controller/Net/WebSocketMessages/Inbound/SessionsStartMessage.cs create mode 100644 MediaBrowser.Controller/Net/WebSocketMessages/Inbound/SessionsStopMessage.cs create mode 100644 MediaBrowser.Controller/Net/WebSocketMessages/InboundWebSocketMessage.cs create mode 100644 MediaBrowser.Controller/Net/WebSocketMessages/Outbound/ActivityLogEntryMessage.cs create mode 100644 MediaBrowser.Controller/Net/WebSocketMessages/Outbound/ForceKeepAliveMessage.cs create mode 100644 MediaBrowser.Controller/Net/WebSocketMessages/Outbound/GeneralCommandMessage.cs create mode 100644 MediaBrowser.Controller/Net/WebSocketMessages/Outbound/LibraryChangedMessage.cs create mode 100644 MediaBrowser.Controller/Net/WebSocketMessages/Outbound/PlayMessage.cs create mode 100644 MediaBrowser.Controller/Net/WebSocketMessages/Outbound/PlaystateMessage.cs create mode 100644 MediaBrowser.Controller/Net/WebSocketMessages/Outbound/PluginInstallationCancelledMessage.cs create mode 100644 MediaBrowser.Controller/Net/WebSocketMessages/Outbound/PluginInstallationCompletedMessage.cs create mode 100644 MediaBrowser.Controller/Net/WebSocketMessages/Outbound/PluginInstallationFailedMessage.cs create mode 100644 MediaBrowser.Controller/Net/WebSocketMessages/Outbound/PluginInstallingMessage.cs create mode 100644 MediaBrowser.Controller/Net/WebSocketMessages/Outbound/PluginUninstalledMessage.cs create mode 100644 MediaBrowser.Controller/Net/WebSocketMessages/Outbound/RefreshProgressMessage.cs create mode 100644 MediaBrowser.Controller/Net/WebSocketMessages/Outbound/RestartRequiredMessage.cs create mode 100644 MediaBrowser.Controller/Net/WebSocketMessages/Outbound/ScheduledTaskEndedMessage.cs create mode 100644 MediaBrowser.Controller/Net/WebSocketMessages/Outbound/ScheduledTasksInfoMessage.cs create mode 100644 MediaBrowser.Controller/Net/WebSocketMessages/Outbound/SeriesTimerCancelledMessage.cs create mode 100644 MediaBrowser.Controller/Net/WebSocketMessages/Outbound/SeriesTimerCreatedMessage.cs create mode 100644 MediaBrowser.Controller/Net/WebSocketMessages/Outbound/ServerRestartingMessage.cs create mode 100644 MediaBrowser.Controller/Net/WebSocketMessages/Outbound/ServerShuttingDownMessage.cs create mode 100644 MediaBrowser.Controller/Net/WebSocketMessages/Outbound/SessionsMessage.cs create mode 100644 MediaBrowser.Controller/Net/WebSocketMessages/Outbound/SyncPlayCommandMessage.cs create mode 100644 MediaBrowser.Controller/Net/WebSocketMessages/Outbound/SyncPlayGroupUpdateCommandMessage.cs create mode 100644 MediaBrowser.Controller/Net/WebSocketMessages/Outbound/SyncPlayGroupUpdateCommandOfGroupInfoMessage.cs create mode 100644 MediaBrowser.Controller/Net/WebSocketMessages/Outbound/SyncPlayGroupUpdateCommandOfGroupStateUpdateMessage.cs create mode 100644 MediaBrowser.Controller/Net/WebSocketMessages/Outbound/SyncPlayGroupUpdateCommandOfPlayQueueUpdateMessage.cs create mode 100644 MediaBrowser.Controller/Net/WebSocketMessages/Outbound/SyncPlayGroupUpdateCommandOfStringMessage.cs create mode 100644 MediaBrowser.Controller/Net/WebSocketMessages/Outbound/TimerCancelledMessage.cs create mode 100644 MediaBrowser.Controller/Net/WebSocketMessages/Outbound/TimerCreatedMessage.cs create mode 100644 MediaBrowser.Controller/Net/WebSocketMessages/Outbound/UserDataChangedMessage.cs create mode 100644 MediaBrowser.Controller/Net/WebSocketMessages/Outbound/UserDeletedMessage.cs create mode 100644 MediaBrowser.Controller/Net/WebSocketMessages/Outbound/UserUpdatedMessage.cs create mode 100644 MediaBrowser.Controller/Net/WebSocketMessages/OutboundWebSocketMessage.cs create mode 100644 MediaBrowser.Controller/Net/WebSocketMessages/Shared/KeepAliveMessage.cs delete mode 100644 MediaBrowser.Model/Net/WebSocketMessage.cs create mode 100644 MediaBrowser.Model/SyncPlay/GroupUpdateOfT.cs delete mode 100644 MediaBrowser.Model/SyncPlay/QueueItem.cs create mode 100644 MediaBrowser.Model/SyncPlay/SyncPlayQueueItem.cs (limited to 'MediaBrowser.Controller/Net') diff --git a/Jellyfin.Server/Filters/AdditionalModelFilter.cs b/Jellyfin.Server/Filters/AdditionalModelFilter.cs index 645696e319..bf38f741cd 100644 --- a/Jellyfin.Server/Filters/AdditionalModelFilter.cs +++ b/Jellyfin.Server/Filters/AdditionalModelFilter.cs @@ -1,12 +1,16 @@ using System; +using System.Collections.Generic; +using System.ComponentModel; using System.Linq; +using System.Reflection; using Jellyfin.Extensions; using Jellyfin.Server.Migrations; using MediaBrowser.Common.Plugins; using MediaBrowser.Controller.Configuration; -using MediaBrowser.Controller.LiveTv; +using MediaBrowser.Controller.Net; +using MediaBrowser.Controller.Net.WebSocketMessages; +using MediaBrowser.Controller.Net.WebSocketMessages.Outbound; using MediaBrowser.Model.ApiClient; -using MediaBrowser.Model.Entities; using MediaBrowser.Model.Session; using MediaBrowser.Model.SyncPlay; using Microsoft.OpenApi.Any; @@ -36,17 +40,141 @@ namespace Jellyfin.Server.Filters /// public void Apply(OpenApiDocument swaggerDoc, DocumentFilterContext context) { - context.SchemaGenerator.GenerateSchema(typeof(LibraryUpdateInfo), context.SchemaRepository); context.SchemaGenerator.GenerateSchema(typeof(IPlugin), context.SchemaRepository); - context.SchemaGenerator.GenerateSchema(typeof(PlayRequest), context.SchemaRepository); - context.SchemaGenerator.GenerateSchema(typeof(PlaystateRequest), context.SchemaRepository); - context.SchemaGenerator.GenerateSchema(typeof(TimerEventInfo), context.SchemaRepository); - context.SchemaGenerator.GenerateSchema(typeof(SendCommand), context.SchemaRepository); - context.SchemaGenerator.GenerateSchema(typeof(GeneralCommandType), context.SchemaRepository); - context.SchemaGenerator.GenerateSchema(typeof(GroupUpdate), context.SchemaRepository); + var webSocketTypes = typeof(WebSocketMessage).Assembly.GetTypes() + .Where(t => t.IsSubclassOf(typeof(WebSocketMessage)) + && !t.IsGenericType + && t != typeof(WebSocketMessageInfo)) + .ToList(); + + var inboundWebSocketSchemas = new List(); + var inboundWebSocketDiscriminators = new Dictionary(); + foreach (var type in webSocketTypes.Where(t => typeof(IInboundWebSocketMessage).IsAssignableFrom(t))) + { + var messageType = (SessionMessageType?)type.GetProperty(nameof(WebSocketMessage.MessageType))?.GetCustomAttribute()?.Value; + if (messageType is null) + { + continue; + } + + var schema = context.SchemaGenerator.GenerateSchema(type, context.SchemaRepository); + inboundWebSocketSchemas.Add(schema); + inboundWebSocketDiscriminators[messageType.ToString()!] = schema.Reference.ReferenceV3; + } + + var inboundWebSocketMessageSchema = new OpenApiSchema + { + Type = "object", + Description = "Represents the list of possible inbound websocket types", + Reference = new OpenApiReference + { + Id = nameof(InboundWebSocketMessage), + Type = ReferenceType.Schema + }, + OneOf = inboundWebSocketSchemas, + Discriminator = new OpenApiDiscriminator + { + PropertyName = nameof(WebSocketMessage.MessageType), + Mapping = inboundWebSocketDiscriminators + } + }; + + context.SchemaRepository.AddDefinition(nameof(InboundWebSocketMessage), inboundWebSocketMessageSchema); + + var outboundWebSocketSchemas = new List(); + var outboundWebSocketDiscriminators = new Dictionary(); + foreach (var type in webSocketTypes.Where(t => typeof(IOutboundWebSocketMessage).IsAssignableFrom(t))) + { + var messageType = (SessionMessageType?)type.GetProperty(nameof(WebSocketMessage.MessageType))?.GetCustomAttribute()?.Value; + if (messageType is null) + { + continue; + } + + // Additional discriminator needed for GroupUpdate models... + if (messageType == SessionMessageType.SyncPlayGroupUpdate && type != typeof(SyncPlayGroupUpdateCommandMessage)) + { + continue; + } + + var schema = context.SchemaGenerator.GenerateSchema(type, context.SchemaRepository); + outboundWebSocketSchemas.Add(schema); + outboundWebSocketDiscriminators.Add(messageType.ToString()!, schema.Reference.ReferenceV3); + } + + var outboundWebSocketMessageSchema = new OpenApiSchema + { + Type = "object", + Description = "Represents the list of possible outbound websocket types", + Reference = new OpenApiReference + { + Id = nameof(OutboundWebSocketMessage), + Type = ReferenceType.Schema + }, + OneOf = outboundWebSocketSchemas, + Discriminator = new OpenApiDiscriminator + { + PropertyName = nameof(WebSocketMessage.MessageType), + Mapping = outboundWebSocketDiscriminators + } + }; + + context.SchemaRepository.AddDefinition(nameof(OutboundWebSocketMessage), outboundWebSocketMessageSchema); + context.SchemaRepository.AddDefinition( + nameof(WebSocketMessage), + new OpenApiSchema + { + Type = "object", + Description = "Represents the possible websocket types", + Reference = new OpenApiReference + { + Id = nameof(WebSocketMessage), + Type = ReferenceType.Schema + }, + OneOf = new[] + { + inboundWebSocketMessageSchema, + outboundWebSocketMessageSchema + } + }); + + // Manually generate sync play GroupUpdate messages. + if (!context.SchemaRepository.Schemas.TryGetValue(nameof(GroupUpdate), out var groupUpdateSchema)) + { + groupUpdateSchema = context.SchemaGenerator.GenerateSchema(typeof(GroupUpdate), context.SchemaRepository); + } + + var groupUpdateOfGroupInfoSchema = context.SchemaGenerator.GenerateSchema(typeof(GroupUpdate), context.SchemaRepository); + var groupUpdateOfGroupStateSchema = context.SchemaGenerator.GenerateSchema(typeof(GroupUpdate), context.SchemaRepository); + var groupUpdateOfStringSchema = context.SchemaGenerator.GenerateSchema(typeof(GroupUpdate), context.SchemaRepository); + var groupUpdateOfPlayQueueSchema = context.SchemaGenerator.GenerateSchema(typeof(GroupUpdate), context.SchemaRepository); + + groupUpdateSchema.OneOf = new List + { + groupUpdateOfGroupInfoSchema, + groupUpdateOfGroupStateSchema, + groupUpdateOfStringSchema, + groupUpdateOfPlayQueueSchema + }; + + groupUpdateSchema.Discriminator = new OpenApiDiscriminator + { + PropertyName = nameof(GroupUpdate.Type), + Mapping = new Dictionary + { + { GroupUpdateType.UserJoined.ToString(), groupUpdateOfStringSchema.Reference.ReferenceV3 }, + { GroupUpdateType.UserLeft.ToString(), groupUpdateOfStringSchema.Reference.ReferenceV3 }, + { GroupUpdateType.GroupJoined.ToString(), groupUpdateOfGroupInfoSchema.Reference.ReferenceV3 }, + { GroupUpdateType.GroupLeft.ToString(), groupUpdateOfStringSchema.Reference.ReferenceV3 }, + { GroupUpdateType.StateUpdate.ToString(), groupUpdateOfGroupStateSchema.Reference.ReferenceV3 }, + { GroupUpdateType.PlayQueue.ToString(), groupUpdateOfPlayQueueSchema.Reference.ReferenceV3 }, + { GroupUpdateType.NotInGroup.ToString(), groupUpdateOfStringSchema.Reference.ReferenceV3 }, + { GroupUpdateType.GroupDoesNotExist.ToString(), groupUpdateOfStringSchema.Reference.ReferenceV3 }, + { GroupUpdateType.LibraryAccessDenied.ToString(), groupUpdateOfStringSchema.Reference.ReferenceV3 } + } + }; - context.SchemaGenerator.GenerateSchema(typeof(SessionMessageType), context.SchemaRepository); context.SchemaGenerator.GenerateSchema(typeof(ServerDiscoveryInfo), context.SchemaRepository); foreach (var configuration in _serverConfigurationManager.GetConfigurationStores()) diff --git a/MediaBrowser.Controller/Net/WebSocketMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessage.cs new file mode 100644 index 0000000000..c02bcd70b6 --- /dev/null +++ b/MediaBrowser.Controller/Net/WebSocketMessage.cs @@ -0,0 +1,28 @@ +using System; +using System.Text.Json.Serialization; +using MediaBrowser.Model.Session; + +namespace MediaBrowser.Controller.Net; + +/// +/// Websocket message without data. +/// +public abstract class WebSocketMessage +{ + /// + /// Gets or sets the type of the message. + /// TODO make this abstract and get only. + /// + public virtual SessionMessageType MessageType { get; set; } + + /// + /// Gets or sets the message id. + /// + public Guid MessageId { get; set; } + + /// + /// Gets or sets the server id. + /// + [JsonIgnore] + public string? ServerId { get; set; } +} diff --git a/MediaBrowser.Controller/Net/WebSocketMessageOfT.cs b/MediaBrowser.Controller/Net/WebSocketMessageOfT.cs new file mode 100644 index 0000000000..7c35c8010d --- /dev/null +++ b/MediaBrowser.Controller/Net/WebSocketMessageOfT.cs @@ -0,0 +1,33 @@ +#pragma warning disable SA1649 // File name must equal class name. + +namespace MediaBrowser.Controller.Net; + +/// +/// Class WebSocketMessage. +/// +/// The type of the data. +// TODO make this abstract, remove empty ctor. +public class WebSocketMessage : WebSocketMessage +{ + /// + /// Initializes a new instance of the class. + /// + public WebSocketMessage() + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The data to send. + protected WebSocketMessage(T data) + { + Data = data; + } + + /// + /// Gets or sets the data. + /// + // TODO make this set only. + public T? Data { get; set; } +} diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/IInboundWebSocketMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/IInboundWebSocketMessage.cs new file mode 100644 index 0000000000..c3cf9955ad --- /dev/null +++ b/MediaBrowser.Controller/Net/WebSocketMessages/IInboundWebSocketMessage.cs @@ -0,0 +1,10 @@ +#pragma warning disable CA1040 + +namespace MediaBrowser.Controller.Net.WebSocketMessages; + +/// +/// Interface representing that the websocket message is inbound. +/// +public interface IInboundWebSocketMessage +{ +} diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/IOutboundWebSocketMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/IOutboundWebSocketMessage.cs new file mode 100644 index 0000000000..c74a254a68 --- /dev/null +++ b/MediaBrowser.Controller/Net/WebSocketMessages/IOutboundWebSocketMessage.cs @@ -0,0 +1,10 @@ +#pragma warning disable CA1040 + +namespace MediaBrowser.Controller.Net.WebSocketMessages; + +/// +/// Interface representing that the websocket message is outbound. +/// +public interface IOutboundWebSocketMessage +{ +} diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Inbound/ActivityLogEntryStartMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Inbound/ActivityLogEntryStartMessage.cs new file mode 100644 index 0000000000..b9f71b9225 --- /dev/null +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Inbound/ActivityLogEntryStartMessage.cs @@ -0,0 +1,25 @@ +using System.Collections.Generic; +using System.ComponentModel; +using MediaBrowser.Model.Activity; +using MediaBrowser.Model.Session; + +namespace MediaBrowser.Controller.Net.WebSocketMessages.Inbound; + +/// +/// Activity log entry start message. +/// +public class ActivityLogEntryStartMessage : WebSocketMessage>, IInboundWebSocketMessage +{ + /// + /// Initializes a new instance of the class. + /// + /// Collection of activity log entries. + public ActivityLogEntryStartMessage(IReadOnlyCollection data) + : base(data) + { + } + + /// + [DefaultValue(SessionMessageType.ActivityLogEntryStart)] + public override SessionMessageType MessageType => SessionMessageType.ActivityLogEntryStart; +} diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Inbound/ActivityLogEntryStopMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Inbound/ActivityLogEntryStopMessage.cs new file mode 100644 index 0000000000..eac129b20a --- /dev/null +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Inbound/ActivityLogEntryStopMessage.cs @@ -0,0 +1,25 @@ +using System.Collections.Generic; +using System.ComponentModel; +using MediaBrowser.Model.Activity; +using MediaBrowser.Model.Session; + +namespace MediaBrowser.Controller.Net.WebSocketMessages.Inbound; + +/// +/// Activity log entry stop message. +/// +public class ActivityLogEntryStopMessage : WebSocketMessage>, IInboundWebSocketMessage +{ + /// + /// Initializes a new instance of the class. + /// + /// Collection of activity log entries. + public ActivityLogEntryStopMessage(IReadOnlyCollection data) + : base(data) + { + } + + /// + [DefaultValue(SessionMessageType.ActivityLogEntryStop)] + public override SessionMessageType MessageType => SessionMessageType.ActivityLogEntryStop; +} diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Inbound/ScheduledTasksInfoStartMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Inbound/ScheduledTasksInfoStartMessage.cs new file mode 100644 index 0000000000..dd2a7145e3 --- /dev/null +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Inbound/ScheduledTasksInfoStartMessage.cs @@ -0,0 +1,25 @@ +using System.Collections.Generic; +using System.ComponentModel; +using MediaBrowser.Model.Session; +using MediaBrowser.Model.Tasks; + +namespace MediaBrowser.Controller.Net.WebSocketMessages.Inbound; + +/// +/// Scheduled tasks info start message. +/// +public class ScheduledTasksInfoStartMessage : WebSocketMessage>, IInboundWebSocketMessage +{ + /// + /// Initializes a new instance of the class. + /// + /// Collection of task info. + public ScheduledTasksInfoStartMessage(IReadOnlyCollection data) + : base(data) + { + } + + /// + [DefaultValue(SessionMessageType.ScheduledTasksInfoStart)] + public override SessionMessageType MessageType => SessionMessageType.ScheduledTasksInfoStart; +} diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Inbound/ScheduledTasksInfoStopMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Inbound/ScheduledTasksInfoStopMessage.cs new file mode 100644 index 0000000000..84e1f01667 --- /dev/null +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Inbound/ScheduledTasksInfoStopMessage.cs @@ -0,0 +1,25 @@ +using System.Collections.Generic; +using System.ComponentModel; +using MediaBrowser.Model.Session; +using MediaBrowser.Model.Tasks; + +namespace MediaBrowser.Controller.Net.WebSocketMessages.Inbound; + +/// +/// Scheduled tasks info stop message. +/// +public class ScheduledTasksInfoStopMessage : WebSocketMessage>, IInboundWebSocketMessage +{ + /// + /// Initializes a new instance of the class. + /// + /// Collection of task info. + public ScheduledTasksInfoStopMessage(IReadOnlyCollection data) + : base(data) + { + } + + /// + [DefaultValue(SessionMessageType.ScheduledTasksInfoStop)] + public override SessionMessageType MessageType => SessionMessageType.ScheduledTasksInfoStop; +} diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Inbound/SessionsStartMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Inbound/SessionsStartMessage.cs new file mode 100644 index 0000000000..e35a5dc3ad --- /dev/null +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Inbound/SessionsStartMessage.cs @@ -0,0 +1,24 @@ +using System.ComponentModel; +using MediaBrowser.Controller.Session; +using MediaBrowser.Model.Session; + +namespace MediaBrowser.Controller.Net.WebSocketMessages.Inbound; + +/// +/// Sessions start message. +/// +public class SessionsStartMessage : WebSocketMessage, IInboundWebSocketMessage +{ + /// + /// Initializes a new instance of the class. + /// + /// Session info. + public SessionsStartMessage(SessionInfo data) + : base(data) + { + } + + /// + [DefaultValue(SessionMessageType.SessionsStart)] + public override SessionMessageType MessageType => SessionMessageType.SessionsStart; +} diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Inbound/SessionsStopMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Inbound/SessionsStopMessage.cs new file mode 100644 index 0000000000..7e3582d640 --- /dev/null +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Inbound/SessionsStopMessage.cs @@ -0,0 +1,24 @@ +using System.ComponentModel; +using MediaBrowser.Controller.Session; +using MediaBrowser.Model.Session; + +namespace MediaBrowser.Controller.Net.WebSocketMessages.Inbound; + +/// +/// Sessions stop message. +/// +public class SessionsStopMessage : WebSocketMessage, IInboundWebSocketMessage +{ + /// + /// Initializes a new instance of the class. + /// + /// Session info. + public SessionsStopMessage(SessionInfo data) + : base(data) + { + } + + /// + [DefaultValue(SessionMessageType.SessionsStop)] + public override SessionMessageType MessageType => SessionMessageType.SessionsStop; +} diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/InboundWebSocketMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/InboundWebSocketMessage.cs new file mode 100644 index 0000000000..20ca888e11 --- /dev/null +++ b/MediaBrowser.Controller/Net/WebSocketMessages/InboundWebSocketMessage.cs @@ -0,0 +1,9 @@ +namespace MediaBrowser.Controller.Net.WebSocketMessages; + +/// +/// Class representing the list of outbound websocket message types. +/// Only used in openapi generation. +/// +public class InboundWebSocketMessage : WebSocketMessage +{ +} diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/ActivityLogEntryMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/ActivityLogEntryMessage.cs new file mode 100644 index 0000000000..5650ee4bbe --- /dev/null +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/ActivityLogEntryMessage.cs @@ -0,0 +1,25 @@ +using System.Collections.Generic; +using System.ComponentModel; +using MediaBrowser.Model.Activity; +using MediaBrowser.Model.Session; + +namespace MediaBrowser.Controller.Net.WebSocketMessages.Outbound; + +/// +/// Activity log created message. +/// +public class ActivityLogEntryMessage : WebSocketMessage>, IOutboundWebSocketMessage +{ + /// + /// Initializes a new instance of the class. + /// + /// List of activity log entries. + public ActivityLogEntryMessage(IReadOnlyList data) + : base(data) + { + } + + /// + [DefaultValue(SessionMessageType.ActivityLogEntry)] + public override SessionMessageType MessageType => SessionMessageType.ActivityLogEntry; +} diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/ForceKeepAliveMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/ForceKeepAliveMessage.cs new file mode 100644 index 0000000000..94ade5e817 --- /dev/null +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/ForceKeepAliveMessage.cs @@ -0,0 +1,23 @@ +using System.ComponentModel; +using MediaBrowser.Model.Session; + +namespace MediaBrowser.Controller.Net.WebSocketMessages.Outbound; + +/// +/// Force keep alive websocket messages. +/// +public class ForceKeepAliveMessage : WebSocketMessage, IOutboundWebSocketMessage +{ + /// + /// Initializes a new instance of the class. + /// + /// The timeout in seconds. + public ForceKeepAliveMessage(int data) + : base(data) + { + } + + /// + [DefaultValue(SessionMessageType.ForceKeepAlive)] + public override SessionMessageType MessageType => SessionMessageType.ForceKeepAlive; +} diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/GeneralCommandMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/GeneralCommandMessage.cs new file mode 100644 index 0000000000..6c71e73f9d --- /dev/null +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/GeneralCommandMessage.cs @@ -0,0 +1,23 @@ +using System.ComponentModel; +using MediaBrowser.Model.Session; + +namespace MediaBrowser.Controller.Net.WebSocketMessages.Outbound; + +/// +/// General command websocket message. +/// +public class GeneralCommandMessage : WebSocketMessage, IOutboundWebSocketMessage +{ + /// + /// Initializes a new instance of the class. + /// + /// The general command. + public GeneralCommandMessage(GeneralCommand data) + : base(data) + { + } + + /// + [DefaultValue(SessionMessageType.GeneralCommand)] + public override SessionMessageType MessageType => SessionMessageType.GeneralCommand; +} diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/LibraryChangedMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/LibraryChangedMessage.cs new file mode 100644 index 0000000000..6432ae8efb --- /dev/null +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/LibraryChangedMessage.cs @@ -0,0 +1,24 @@ +using System.ComponentModel; +using MediaBrowser.Model.Entities; +using MediaBrowser.Model.Session; + +namespace MediaBrowser.Controller.Net.WebSocketMessages.Outbound; + +/// +/// Library changed message. +/// +public class LibraryChangedMessage : WebSocketMessage, IOutboundWebSocketMessage +{ + /// + /// Initializes a new instance of the class. + /// + /// The library update info. + public LibraryChangedMessage(LibraryUpdateInfo data) + : base(data) + { + } + + /// + [DefaultValue(SessionMessageType.LibraryChanged)] + public override SessionMessageType MessageType => SessionMessageType.LibraryChanged; +} diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/PlayMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/PlayMessage.cs new file mode 100644 index 0000000000..7f943bda10 --- /dev/null +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/PlayMessage.cs @@ -0,0 +1,23 @@ +using System.ComponentModel; +using MediaBrowser.Model.Session; + +namespace MediaBrowser.Controller.Net.WebSocketMessages.Outbound; + +/// +/// Play command websocket message. +/// +public class PlayMessage : WebSocketMessage, IOutboundWebSocketMessage +{ + /// + /// Initializes a new instance of the class. + /// + /// The play request. + public PlayMessage(PlayRequest data) + : base(data) + { + } + + /// + [DefaultValue(SessionMessageType.Play)] + public override SessionMessageType MessageType => SessionMessageType.Play; +} diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/PlaystateMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/PlaystateMessage.cs new file mode 100644 index 0000000000..804ccb37d6 --- /dev/null +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/PlaystateMessage.cs @@ -0,0 +1,23 @@ +using System.ComponentModel; +using MediaBrowser.Model.Session; + +namespace MediaBrowser.Controller.Net.WebSocketMessages.Outbound; + +/// +/// Playstate message. +/// +public class PlaystateMessage : WebSocketMessage, IOutboundWebSocketMessage +{ + /// + /// Initializes a new instance of the class. + /// + /// Playstate request data. + public PlaystateMessage(PlaystateRequest data) + : base(data) + { + } + + /// + [DefaultValue(SessionMessageType.Playstate)] + public override SessionMessageType MessageType => SessionMessageType.Playstate; +} diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/PluginInstallationCancelledMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/PluginInstallationCancelledMessage.cs new file mode 100644 index 0000000000..3d7dc5c937 --- /dev/null +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/PluginInstallationCancelledMessage.cs @@ -0,0 +1,24 @@ +using System.ComponentModel; +using MediaBrowser.Model.Session; +using MediaBrowser.Model.Updates; + +namespace MediaBrowser.Controller.Net.WebSocketMessages.Outbound; + +/// +/// Plugin installation cancelled message. +/// +public class PluginInstallationCancelledMessage : WebSocketMessage, IOutboundWebSocketMessage +{ + /// + /// Initializes a new instance of the class. + /// + /// Installation info. + public PluginInstallationCancelledMessage(InstallationInfo data) + : base(data) + { + } + + /// + [DefaultValue(SessionMessageType.PackageInstallationCancelled)] + public override SessionMessageType MessageType => SessionMessageType.PackageInstallationCancelled; +} diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/PluginInstallationCompletedMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/PluginInstallationCompletedMessage.cs new file mode 100644 index 0000000000..81268007fd --- /dev/null +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/PluginInstallationCompletedMessage.cs @@ -0,0 +1,24 @@ +using System.ComponentModel; +using MediaBrowser.Model.Session; +using MediaBrowser.Model.Updates; + +namespace MediaBrowser.Controller.Net.WebSocketMessages.Outbound; + +/// +/// Plugin installation completed message. +/// +public class PluginInstallationCompletedMessage : WebSocketMessage, IOutboundWebSocketMessage +{ + /// + /// Initializes a new instance of the class. + /// + /// Installation info. + public PluginInstallationCompletedMessage(InstallationInfo data) + : base(data) + { + } + + /// + [DefaultValue(SessionMessageType.PackageInstallationCompleted)] + public override SessionMessageType MessageType => SessionMessageType.PackageInstallationCompleted; +} diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/PluginInstallationFailedMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/PluginInstallationFailedMessage.cs new file mode 100644 index 0000000000..9177f12938 --- /dev/null +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/PluginInstallationFailedMessage.cs @@ -0,0 +1,24 @@ +using System.ComponentModel; +using MediaBrowser.Model.Session; +using MediaBrowser.Model.Updates; + +namespace MediaBrowser.Controller.Net.WebSocketMessages.Outbound; + +/// +/// Plugin installation failed message. +/// +public class PluginInstallationFailedMessage : WebSocketMessage, IOutboundWebSocketMessage +{ + /// + /// Initializes a new instance of the class. + /// + /// Installation info. + public PluginInstallationFailedMessage(InstallationInfo data) + : base(data) + { + } + + /// + [DefaultValue(SessionMessageType.PackageInstallationFailed)] + public override SessionMessageType MessageType => SessionMessageType.PackageInstallationFailed; +} diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/PluginInstallingMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/PluginInstallingMessage.cs new file mode 100644 index 0000000000..e371440a0f --- /dev/null +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/PluginInstallingMessage.cs @@ -0,0 +1,24 @@ +using System.ComponentModel; +using MediaBrowser.Model.Session; +using MediaBrowser.Model.Updates; + +namespace MediaBrowser.Controller.Net.WebSocketMessages.Outbound; + +/// +/// Package installing message. +/// +public class PluginInstallingMessage : WebSocketMessage, IOutboundWebSocketMessage +{ + /// + /// Initializes a new instance of the class. + /// + /// Installation info. + public PluginInstallingMessage(InstallationInfo data) + : base(data) + { + } + + /// + [DefaultValue(SessionMessageType.PackageInstalling)] + public override SessionMessageType MessageType => SessionMessageType.PackageInstalling; +} diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/PluginUninstalledMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/PluginUninstalledMessage.cs new file mode 100644 index 0000000000..b2994fc956 --- /dev/null +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/PluginUninstalledMessage.cs @@ -0,0 +1,24 @@ +using System.ComponentModel; +using MediaBrowser.Model.Plugins; +using MediaBrowser.Model.Session; + +namespace MediaBrowser.Controller.Net.WebSocketMessages.Outbound; + +/// +/// Plugin uninstalled message. +/// +public class PluginUninstalledMessage : WebSocketMessage, IOutboundWebSocketMessage +{ + /// + /// Initializes a new instance of the class. + /// + /// Plugin info. + public PluginUninstalledMessage(PluginInfo data) + : base(data) + { + } + + /// + [DefaultValue(SessionMessageType.PackageUninstalled)] + public override SessionMessageType MessageType => SessionMessageType.PackageUninstalled; +} diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/RefreshProgressMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/RefreshProgressMessage.cs new file mode 100644 index 0000000000..42dbc30295 --- /dev/null +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/RefreshProgressMessage.cs @@ -0,0 +1,24 @@ +using System.Collections.Generic; +using System.ComponentModel; +using MediaBrowser.Model.Session; + +namespace MediaBrowser.Controller.Net.WebSocketMessages.Outbound; + +/// +/// Refresh progress message. +/// +public class RefreshProgressMessage : WebSocketMessage>, IOutboundWebSocketMessage +{ + /// + /// Initializes a new instance of the class. + /// + /// Refresh progress data. + public RefreshProgressMessage(Dictionary data) + : base(data) + { + } + + /// + [DefaultValue(SessionMessageType.RefreshProgress)] + public override SessionMessageType MessageType => SessionMessageType.RefreshProgress; +} diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/RestartRequiredMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/RestartRequiredMessage.cs new file mode 100644 index 0000000000..3f3d9e4c84 --- /dev/null +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/RestartRequiredMessage.cs @@ -0,0 +1,14 @@ +using System.ComponentModel; +using MediaBrowser.Model.Session; + +namespace MediaBrowser.Controller.Net.WebSocketMessages.Outbound; + +/// +/// Restart required. +/// +public class RestartRequiredMessage : WebSocketMessage, IOutboundWebSocketMessage +{ + /// + [DefaultValue(SessionMessageType.RestartRequired)] + public override SessionMessageType MessageType => SessionMessageType.RestartRequired; +} diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/ScheduledTaskEndedMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/ScheduledTaskEndedMessage.cs new file mode 100644 index 0000000000..d69662b004 --- /dev/null +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/ScheduledTaskEndedMessage.cs @@ -0,0 +1,24 @@ +using System.ComponentModel; +using MediaBrowser.Model.Session; +using MediaBrowser.Model.Tasks; + +namespace MediaBrowser.Controller.Net.WebSocketMessages.Outbound; + +/// +/// Scheduled task ended message. +/// +public class ScheduledTaskEndedMessage : WebSocketMessage, IOutboundWebSocketMessage +{ + /// + /// Initializes a new instance of the class. + /// + /// Task result. + public ScheduledTaskEndedMessage(TaskResult data) + : base(data) + { + } + + /// + [DefaultValue(SessionMessageType.ScheduledTaskEnded)] + public override SessionMessageType MessageType => SessionMessageType.ScheduledTaskEnded; +} diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/ScheduledTasksInfoMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/ScheduledTasksInfoMessage.cs new file mode 100644 index 0000000000..41a05b0de2 --- /dev/null +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/ScheduledTasksInfoMessage.cs @@ -0,0 +1,25 @@ +using System.Collections.Generic; +using System.ComponentModel; +using MediaBrowser.Model.Session; +using MediaBrowser.Model.Tasks; + +namespace MediaBrowser.Controller.Net.WebSocketMessages.Outbound; + +/// +/// Scheduled tasks info message. +/// +public class ScheduledTasksInfoMessage : WebSocketMessage>, IOutboundWebSocketMessage +{ + /// + /// Initializes a new instance of the class. + /// + /// List of task infos. + public ScheduledTasksInfoMessage(IReadOnlyList data) + : base(data) + { + } + + /// + [DefaultValue(SessionMessageType.ScheduledTasksInfo)] + public override SessionMessageType MessageType => SessionMessageType.ScheduledTasksInfo; +} diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/SeriesTimerCancelledMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/SeriesTimerCancelledMessage.cs new file mode 100644 index 0000000000..d4950b8b67 --- /dev/null +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/SeriesTimerCancelledMessage.cs @@ -0,0 +1,24 @@ +using System.ComponentModel; +using MediaBrowser.Controller.LiveTv; +using MediaBrowser.Model.Session; + +namespace MediaBrowser.Controller.Net.WebSocketMessages.Outbound; + +/// +/// Series timer cancelled message. +/// +public class SeriesTimerCancelledMessage : WebSocketMessage, IOutboundWebSocketMessage +{ + /// + /// Initializes a new instance of the class. + /// + /// The timer event info. + public SeriesTimerCancelledMessage(TimerEventInfo data) + : base(data) + { + } + + /// + [DefaultValue(SessionMessageType.SeriesTimerCancelled)] + public override SessionMessageType MessageType => SessionMessageType.SeriesTimerCancelled; +} diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/SeriesTimerCreatedMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/SeriesTimerCreatedMessage.cs new file mode 100644 index 0000000000..091c10be6d --- /dev/null +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/SeriesTimerCreatedMessage.cs @@ -0,0 +1,24 @@ +using System.ComponentModel; +using MediaBrowser.Controller.LiveTv; +using MediaBrowser.Model.Session; + +namespace MediaBrowser.Controller.Net.WebSocketMessages.Outbound; + +/// +/// Series timer created message. +/// +public class SeriesTimerCreatedMessage : WebSocketMessage, IOutboundWebSocketMessage +{ + /// + /// Initializes a new instance of the class. + /// + /// timer event info. + public SeriesTimerCreatedMessage(TimerEventInfo data) + : base(data) + { + } + + /// + [DefaultValue(SessionMessageType.SeriesTimerCreated)] + public override SessionMessageType MessageType => SessionMessageType.SeriesTimerCreated; +} diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/ServerRestartingMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/ServerRestartingMessage.cs new file mode 100644 index 0000000000..a465d8b008 --- /dev/null +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/ServerRestartingMessage.cs @@ -0,0 +1,14 @@ +using System.ComponentModel; +using MediaBrowser.Model.Session; + +namespace MediaBrowser.Controller.Net.WebSocketMessages.Outbound; + +/// +/// Server restarting down message. +/// +public class ServerRestartingMessage : WebSocketMessage, IOutboundWebSocketMessage +{ + /// + [DefaultValue(SessionMessageType.ServerRestarting)] + public override SessionMessageType MessageType => SessionMessageType.ServerRestarting; +} diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/ServerShuttingDownMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/ServerShuttingDownMessage.cs new file mode 100644 index 0000000000..0b998a5239 --- /dev/null +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/ServerShuttingDownMessage.cs @@ -0,0 +1,14 @@ +using System.ComponentModel; +using MediaBrowser.Model.Session; + +namespace MediaBrowser.Controller.Net.WebSocketMessages.Outbound; + +/// +/// Server shutting down message. +/// +public class ServerShuttingDownMessage : WebSocketMessage, IOutboundWebSocketMessage +{ + /// + [DefaultValue(SessionMessageType.ServerShuttingDown)] + public override SessionMessageType MessageType => SessionMessageType.ServerShuttingDown; +} diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/SessionsMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/SessionsMessage.cs new file mode 100644 index 0000000000..4c91e0bca2 --- /dev/null +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/SessionsMessage.cs @@ -0,0 +1,24 @@ +using System.ComponentModel; +using MediaBrowser.Controller.Session; +using MediaBrowser.Model.Session; + +namespace MediaBrowser.Controller.Net.WebSocketMessages.Outbound; + +/// +/// Sessions message. +/// +public class SessionsMessage : WebSocketMessage, IOutboundWebSocketMessage +{ + /// + /// Initializes a new instance of the class. + /// + /// Session info. + public SessionsMessage(SessionInfo data) + : base(data) + { + } + + /// + [DefaultValue(SessionMessageType.Sessions)] + public override SessionMessageType MessageType => SessionMessageType.Sessions; +} diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/SyncPlayCommandMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/SyncPlayCommandMessage.cs new file mode 100644 index 0000000000..17a0fc66e5 --- /dev/null +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/SyncPlayCommandMessage.cs @@ -0,0 +1,24 @@ +using System.ComponentModel; +using MediaBrowser.Model.Session; +using MediaBrowser.Model.SyncPlay; + +namespace MediaBrowser.Controller.Net.WebSocketMessages.Outbound; + +/// +/// Sync play command. +/// +public class SyncPlayCommandMessage : WebSocketMessage, IOutboundWebSocketMessage +{ + /// + /// Initializes a new instance of the class. + /// + /// The send command. + public SyncPlayCommandMessage(SendCommand data) + : base(data) + { + } + + /// + [DefaultValue(SessionMessageType.SyncPlayCommand)] + public override SessionMessageType MessageType => SessionMessageType.SyncPlayCommand; +} diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/SyncPlayGroupUpdateCommandMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/SyncPlayGroupUpdateCommandMessage.cs new file mode 100644 index 0000000000..d145d0e01a --- /dev/null +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/SyncPlayGroupUpdateCommandMessage.cs @@ -0,0 +1,24 @@ +using System.ComponentModel; +using MediaBrowser.Model.Session; +using MediaBrowser.Model.SyncPlay; + +namespace MediaBrowser.Controller.Net.WebSocketMessages.Outbound; + +/// +/// Untyped sync play command. +/// +public class SyncPlayGroupUpdateCommandMessage : WebSocketMessage, IOutboundWebSocketMessage +{ + /// + /// Initializes a new instance of the class. + /// + /// The send command. + public SyncPlayGroupUpdateCommandMessage(GroupUpdate data) + : base(data) + { + } + + /// + [DefaultValue(SessionMessageType.SyncPlayGroupUpdate)] + public override SessionMessageType MessageType => SessionMessageType.SyncPlayGroupUpdate; +} diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/SyncPlayGroupUpdateCommandOfGroupInfoMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/SyncPlayGroupUpdateCommandOfGroupInfoMessage.cs new file mode 100644 index 0000000000..668392c66b --- /dev/null +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/SyncPlayGroupUpdateCommandOfGroupInfoMessage.cs @@ -0,0 +1,25 @@ +using System.ComponentModel; +using MediaBrowser.Model.Session; +using MediaBrowser.Model.SyncPlay; + +namespace MediaBrowser.Controller.Net.WebSocketMessages.Outbound; + +/// +/// Sync play group update command with group info. +/// GroupUpdateTypes: GroupJoined. +/// +public class SyncPlayGroupUpdateCommandOfGroupInfoMessage : WebSocketMessage>, IOutboundWebSocketMessage +{ + /// + /// Initializes a new instance of the class. + /// + /// The group info. + public SyncPlayGroupUpdateCommandOfGroupInfoMessage(GroupUpdate data) + : base(data) + { + } + + /// + [DefaultValue(SessionMessageType.SyncPlayGroupUpdate)] + public override SessionMessageType MessageType => SessionMessageType.SyncPlayGroupUpdate; +} diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/SyncPlayGroupUpdateCommandOfGroupStateUpdateMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/SyncPlayGroupUpdateCommandOfGroupStateUpdateMessage.cs new file mode 100644 index 0000000000..ec8c3344f4 --- /dev/null +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/SyncPlayGroupUpdateCommandOfGroupStateUpdateMessage.cs @@ -0,0 +1,25 @@ +using System.ComponentModel; +using MediaBrowser.Model.Session; +using MediaBrowser.Model.SyncPlay; + +namespace MediaBrowser.Controller.Net.WebSocketMessages.Outbound; + +/// +/// Sync play group update command with group state update. +/// GroupUpdateTypes: StateUpdate. +/// +public class SyncPlayGroupUpdateCommandOfGroupStateUpdateMessage : WebSocketMessage>, IOutboundWebSocketMessage +{ + /// + /// Initializes a new instance of the class. + /// + /// The group info. + public SyncPlayGroupUpdateCommandOfGroupStateUpdateMessage(GroupUpdate data) + : base(data) + { + } + + /// + [DefaultValue(SessionMessageType.SyncPlayGroupUpdate)] + public override SessionMessageType MessageType => SessionMessageType.SyncPlayGroupUpdate; +} diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/SyncPlayGroupUpdateCommandOfPlayQueueUpdateMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/SyncPlayGroupUpdateCommandOfPlayQueueUpdateMessage.cs new file mode 100644 index 0000000000..465363f143 --- /dev/null +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/SyncPlayGroupUpdateCommandOfPlayQueueUpdateMessage.cs @@ -0,0 +1,25 @@ +using System.ComponentModel; +using MediaBrowser.Model.Session; +using MediaBrowser.Model.SyncPlay; + +namespace MediaBrowser.Controller.Net.WebSocketMessages.Outbound; + +/// +/// Sync play group update command with play queue update. +/// GroupUpdateTypes: PlayQueue. +/// +public class SyncPlayGroupUpdateCommandOfPlayQueueUpdateMessage : WebSocketMessage>, IOutboundWebSocketMessage +{ + /// + /// Initializes a new instance of the class. + /// + /// The play queue update. + public SyncPlayGroupUpdateCommandOfPlayQueueUpdateMessage(GroupUpdate data) + : base(data) + { + } + + /// + [DefaultValue(SessionMessageType.SyncPlayGroupUpdate)] + public override SessionMessageType MessageType => SessionMessageType.SyncPlayGroupUpdate; +} diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/SyncPlayGroupUpdateCommandOfStringMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/SyncPlayGroupUpdateCommandOfStringMessage.cs new file mode 100644 index 0000000000..b87e9bf715 --- /dev/null +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/SyncPlayGroupUpdateCommandOfStringMessage.cs @@ -0,0 +1,25 @@ +using System.ComponentModel; +using MediaBrowser.Model.Session; +using MediaBrowser.Model.SyncPlay; + +namespace MediaBrowser.Controller.Net.WebSocketMessages.Outbound; + +/// +/// Sync play group update command with string. +/// GroupUpdateTypes: GroupDoesNotExist (error), LibraryAccessDenied (error), NotInGroup (error), GroupLeft (groupId), UserJoined (username), UserLeft (username). +/// +public class SyncPlayGroupUpdateCommandOfStringMessage : WebSocketMessage>, IOutboundWebSocketMessage +{ + /// + /// Initializes a new instance of the class. + /// + /// The send command. + public SyncPlayGroupUpdateCommandOfStringMessage(GroupUpdate data) + : base(data) + { + } + + /// + [DefaultValue(SessionMessageType.SyncPlayGroupUpdate)] + public override SessionMessageType MessageType => SessionMessageType.SyncPlayGroupUpdate; +} diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/TimerCancelledMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/TimerCancelledMessage.cs new file mode 100644 index 0000000000..0e70549ef8 --- /dev/null +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/TimerCancelledMessage.cs @@ -0,0 +1,24 @@ +using System.ComponentModel; +using MediaBrowser.Controller.LiveTv; +using MediaBrowser.Model.Session; + +namespace MediaBrowser.Controller.Net.WebSocketMessages.Outbound; + +/// +/// Timer cancelled message. +/// +public class TimerCancelledMessage : WebSocketMessage, IOutboundWebSocketMessage +{ + /// + /// Initializes a new instance of the class. + /// + /// Timer event info. + public TimerCancelledMessage(TimerEventInfo data) + : base(data) + { + } + + /// + [DefaultValue(SessionMessageType.TimerCancelled)] + public override SessionMessageType MessageType => SessionMessageType.TimerCancelled; +} diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/TimerCreatedMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/TimerCreatedMessage.cs new file mode 100644 index 0000000000..295b3081ce --- /dev/null +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/TimerCreatedMessage.cs @@ -0,0 +1,24 @@ +using System.ComponentModel; +using MediaBrowser.Controller.LiveTv; +using MediaBrowser.Model.Session; + +namespace MediaBrowser.Controller.Net.WebSocketMessages.Outbound; + +/// +/// Timer created message. +/// +public class TimerCreatedMessage : WebSocketMessage, IOutboundWebSocketMessage +{ + /// + /// Initializes a new instance of the class. + /// + /// Timer event info. + public TimerCreatedMessage(TimerEventInfo data) + : base(data) + { + } + + /// + [DefaultValue(SessionMessageType.TimerCreated)] + public override SessionMessageType MessageType => SessionMessageType.TimerCreated; +} diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/UserDataChangedMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/UserDataChangedMessage.cs new file mode 100644 index 0000000000..b60769540d --- /dev/null +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/UserDataChangedMessage.cs @@ -0,0 +1,23 @@ +using System.ComponentModel; +using MediaBrowser.Model.Session; + +namespace MediaBrowser.Controller.Net.WebSocketMessages.Outbound; + +/// +/// User data changed message. +/// +public class UserDataChangedMessage : WebSocketMessage, IOutboundWebSocketMessage +{ + /// + /// Initializes a new instance of the class. + /// + /// The data change info. + public UserDataChangedMessage(UserDataChangeInfo data) + : base(data) + { + } + + /// + [DefaultValue(SessionMessageType.UserDataChanged)] + public override SessionMessageType MessageType => SessionMessageType.UserDataChanged; +} diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/UserDeletedMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/UserDeletedMessage.cs new file mode 100644 index 0000000000..6d527be7f2 --- /dev/null +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/UserDeletedMessage.cs @@ -0,0 +1,24 @@ +using System; +using System.ComponentModel; +using MediaBrowser.Model.Session; + +namespace MediaBrowser.Controller.Net.WebSocketMessages.Outbound; + +/// +/// User deleted message. +/// +public class UserDeletedMessage : WebSocketMessage, IOutboundWebSocketMessage +{ + /// + /// Initializes a new instance of the class. + /// + /// The user id. + public UserDeletedMessage(Guid data) + : base(data) + { + } + + /// + [DefaultValue(SessionMessageType.UserDeleted)] + public override SessionMessageType MessageType => SessionMessageType.UserDeleted; +} diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/UserUpdatedMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/UserUpdatedMessage.cs new file mode 100644 index 0000000000..99e9a1f911 --- /dev/null +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/UserUpdatedMessage.cs @@ -0,0 +1,24 @@ +using System.ComponentModel; +using MediaBrowser.Model.Dto; +using MediaBrowser.Model.Session; + +namespace MediaBrowser.Controller.Net.WebSocketMessages.Outbound; + +/// +/// User updated message. +/// +public class UserUpdatedMessage : WebSocketMessage, IOutboundWebSocketMessage +{ + /// + /// Initializes a new instance of the class. + /// + /// The user dto. + public UserUpdatedMessage(UserDto data) + : base(data) + { + } + + /// + [DefaultValue(SessionMessageType.UserUpdated)] + public override SessionMessageType MessageType => SessionMessageType.UserUpdated; +} diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/OutboundWebSocketMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/OutboundWebSocketMessage.cs new file mode 100644 index 0000000000..dba3c8392b --- /dev/null +++ b/MediaBrowser.Controller/Net/WebSocketMessages/OutboundWebSocketMessage.cs @@ -0,0 +1,9 @@ +namespace MediaBrowser.Controller.Net.WebSocketMessages; + +/// +/// Class representing the list of outbound websocket message types. +/// Only used in openapi generation. +/// +public class OutboundWebSocketMessage : WebSocketMessage +{ +} diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Shared/KeepAliveMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Shared/KeepAliveMessage.cs new file mode 100644 index 0000000000..7f636212ca --- /dev/null +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Shared/KeepAliveMessage.cs @@ -0,0 +1,23 @@ +using System.ComponentModel; +using MediaBrowser.Model.Session; + +namespace MediaBrowser.Controller.Net.WebSocketMessages.Shared; + +/// +/// Keep alive websocket messages. +/// +public class KeepAliveMessage : WebSocketMessage, IInboundWebSocketMessage, IOutboundWebSocketMessage +{ + /// + /// Initializes a new instance of the class. + /// + /// The seconds to keep alive for. + public KeepAliveMessage(int data) + : base(data) + { + } + + /// + [DefaultValue(SessionMessageType.KeepAlive)] + public override SessionMessageType MessageType => SessionMessageType.KeepAlive; +} diff --git a/MediaBrowser.Controller/SyncPlay/Queue/PlayQueueManager.cs b/MediaBrowser.Controller/SyncPlay/Queue/PlayQueueManager.cs index bdebbbfd49..c0a168192e 100644 --- a/MediaBrowser.Controller/SyncPlay/Queue/PlayQueueManager.cs +++ b/MediaBrowser.Controller/SyncPlay/Queue/PlayQueueManager.cs @@ -23,13 +23,13 @@ namespace MediaBrowser.Controller.SyncPlay.Queue /// The sorted playlist. /// /// The sorted playlist, or play queue of the group. - private List _sortedPlaylist = new List(); + private List _sortedPlaylist = new List(); /// /// The shuffled playlist. /// /// The shuffled playlist, or play queue of the group. - private List _shuffledPlaylist = new List(); + private List _shuffledPlaylist = new List(); /// /// Initializes a new instance of the class. @@ -76,7 +76,7 @@ namespace MediaBrowser.Controller.SyncPlay.Queue /// Gets the current playlist considering the shuffle mode. /// /// The playlist. - public IReadOnlyList GetPlaylist() + public IReadOnlyList GetPlaylist() { return GetPlaylistInternal(); } @@ -93,7 +93,7 @@ namespace MediaBrowser.Controller.SyncPlay.Queue _sortedPlaylist = CreateQueueItemsFromArray(items); if (ShuffleMode.Equals(GroupShuffleMode.Shuffle)) { - _shuffledPlaylist = new List(_sortedPlaylist); + _shuffledPlaylist = new List(_sortedPlaylist); _shuffledPlaylist.Shuffle(); } @@ -125,14 +125,14 @@ namespace MediaBrowser.Controller.SyncPlay.Queue { if (PlayingItemIndex == NoPlayingItemIndex) { - _shuffledPlaylist = new List(_sortedPlaylist); + _shuffledPlaylist = new List(_sortedPlaylist); _shuffledPlaylist.Shuffle(); } else if (ShuffleMode.Equals(GroupShuffleMode.Sorted)) { // First time shuffle. var playingItem = _sortedPlaylist[PlayingItemIndex]; - _shuffledPlaylist = new List(_sortedPlaylist); + _shuffledPlaylist = new List(_sortedPlaylist); _shuffledPlaylist.RemoveAt(PlayingItemIndex); _shuffledPlaylist.Shuffle(); _shuffledPlaylist.Insert(0, playingItem); @@ -407,7 +407,7 @@ namespace MediaBrowser.Controller.SyncPlay.Queue /// Gets the next item in the playlist considering repeat mode and shuffle mode. /// /// The next item in the playlist. - public QueueItem GetNextItemPlaylistId() + public SyncPlayQueueItem GetNextItemPlaylistId() { int newIndex; var playlist = GetPlaylistInternal(); @@ -502,12 +502,12 @@ namespace MediaBrowser.Controller.SyncPlay.Queue /// Creates a list from the array of items. Each item is given an unique playlist identifier. /// /// The list of queue items. - private List CreateQueueItemsFromArray(IReadOnlyList items) + private List CreateQueueItemsFromArray(IReadOnlyList items) { - var list = new List(); + var list = new List(); foreach (var item in items) { - var queueItem = new QueueItem(item); + var queueItem = new SyncPlayQueueItem(item); list.Add(queueItem); } @@ -518,7 +518,7 @@ namespace MediaBrowser.Controller.SyncPlay.Queue /// Gets the current playlist considering the shuffle mode. /// /// The playlist. - private List GetPlaylistInternal() + private List GetPlaylistInternal() { if (ShuffleMode.Equals(GroupShuffleMode.Shuffle)) { @@ -532,7 +532,7 @@ namespace MediaBrowser.Controller.SyncPlay.Queue /// Gets the current playing item, depending on the shuffle mode. /// /// The playing item. - private QueueItem GetPlayingItem() + private SyncPlayQueueItem GetPlayingItem() { if (PlayingItemIndex == NoPlayingItemIndex) { diff --git a/MediaBrowser.Model/Net/WebSocketMessage.cs b/MediaBrowser.Model/Net/WebSocketMessage.cs deleted file mode 100644 index b00158cb33..0000000000 --- a/MediaBrowser.Model/Net/WebSocketMessage.cs +++ /dev/null @@ -1,31 +0,0 @@ -#nullable disable -#pragma warning disable CS1591 - -using System; -using MediaBrowser.Model.Session; - -namespace MediaBrowser.Model.Net -{ - /// - /// Class WebSocketMessage. - /// - /// The type of the data. - public class WebSocketMessage - { - /// - /// Gets or sets the type of the message. - /// - /// The type of the message. - public SessionMessageType MessageType { get; set; } - - public Guid MessageId { get; set; } - - public string ServerId { get; set; } - - /// - /// Gets or sets the data. - /// - /// The data. - public T Data { get; set; } - } -} diff --git a/MediaBrowser.Model/SyncPlay/GroupUpdate.cs b/MediaBrowser.Model/SyncPlay/GroupUpdate.cs index 6f159d653c..ec67d7ea87 100644 --- a/MediaBrowser.Model/SyncPlay/GroupUpdate.cs +++ b/MediaBrowser.Model/SyncPlay/GroupUpdate.cs @@ -1,42 +1,30 @@ using System; -namespace MediaBrowser.Model.SyncPlay +namespace MediaBrowser.Model.SyncPlay; + +/// +/// Group update without data. +/// +public abstract class GroupUpdate { /// - /// Class GroupUpdate. + /// Initializes a new instance of the class. /// - /// The type of the data of the message. - public class GroupUpdate + /// The group identifier. + protected GroupUpdate(Guid groupId) { - /// - /// Initializes a new instance of the class. - /// - /// The group identifier. - /// The update type. - /// The update data. - public GroupUpdate(Guid groupId, GroupUpdateType type, T data) - { - GroupId = groupId; - Type = type; - Data = data; - } - - /// - /// Gets the group identifier. - /// - /// The group identifier. - public Guid GroupId { get; } + GroupId = groupId; + } - /// - /// Gets the update type. - /// - /// The update type. - public GroupUpdateType Type { get; } + /// + /// Gets the group identifier. + /// + /// The group identifier. + public Guid GroupId { get; } - /// - /// Gets the update data. - /// - /// The update data. - public T Data { get; } - } + /// + /// Gets the update type. + /// + /// The update type. + public GroupUpdateType Type { get; init; } } diff --git a/MediaBrowser.Model/SyncPlay/GroupUpdateOfT.cs b/MediaBrowser.Model/SyncPlay/GroupUpdateOfT.cs new file mode 100644 index 0000000000..25cd444611 --- /dev/null +++ b/MediaBrowser.Model/SyncPlay/GroupUpdateOfT.cs @@ -0,0 +1,31 @@ +#pragma warning disable SA1649 + +using System; + +namespace MediaBrowser.Model.SyncPlay; + +/// +/// Class GroupUpdate. +/// +/// The type of the data of the message. +public class GroupUpdate : GroupUpdate +{ + /// + /// Initializes a new instance of the class. + /// + /// The group identifier. + /// The update type. + /// The update data. + public GroupUpdate(Guid groupId, GroupUpdateType type, T data) + : base(groupId) + { + Data = data; + Type = type; + } + + /// + /// Gets the update data. + /// + /// The update data. + public T Data { get; } +} diff --git a/MediaBrowser.Model/SyncPlay/PlayQueueUpdate.cs b/MediaBrowser.Model/SyncPlay/PlayQueueUpdate.cs index cce99c77d5..376d926c9a 100644 --- a/MediaBrowser.Model/SyncPlay/PlayQueueUpdate.cs +++ b/MediaBrowser.Model/SyncPlay/PlayQueueUpdate.cs @@ -19,7 +19,7 @@ namespace MediaBrowser.Model.SyncPlay /// The playing item status. /// The shuffle mode. /// The repeat mode. - public PlayQueueUpdate(PlayQueueUpdateReason reason, DateTime lastUpdate, IReadOnlyList playlist, int playingItemIndex, long startPositionTicks, bool isPlaying, GroupShuffleMode shuffleMode, GroupRepeatMode repeatMode) + public PlayQueueUpdate(PlayQueueUpdateReason reason, DateTime lastUpdate, IReadOnlyList playlist, int playingItemIndex, long startPositionTicks, bool isPlaying, GroupShuffleMode shuffleMode, GroupRepeatMode repeatMode) { Reason = reason; LastUpdate = lastUpdate; @@ -47,7 +47,7 @@ namespace MediaBrowser.Model.SyncPlay /// Gets the playlist. /// /// The playlist. - public IReadOnlyList Playlist { get; } + public IReadOnlyList Playlist { get; } /// /// Gets the playing item index in the playlist. diff --git a/MediaBrowser.Model/SyncPlay/QueueItem.cs b/MediaBrowser.Model/SyncPlay/QueueItem.cs deleted file mode 100644 index a6dcc109ed..0000000000 --- a/MediaBrowser.Model/SyncPlay/QueueItem.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; - -namespace MediaBrowser.Model.SyncPlay -{ - /// - /// Class QueueItem. - /// - public class QueueItem - { - /// - /// Initializes a new instance of the class. - /// - /// The item identifier. - public QueueItem(Guid itemId) - { - ItemId = itemId; - } - - /// - /// Gets the item identifier. - /// - /// The item identifier. - public Guid ItemId { get; } - - /// - /// Gets the playlist identifier of the item. - /// - /// The playlist identifier of the item. - public Guid PlaylistItemId { get; } = Guid.NewGuid(); - } -} diff --git a/MediaBrowser.Model/SyncPlay/SyncPlayQueueItem.cs b/MediaBrowser.Model/SyncPlay/SyncPlayQueueItem.cs new file mode 100644 index 0000000000..da81fecbdc --- /dev/null +++ b/MediaBrowser.Model/SyncPlay/SyncPlayQueueItem.cs @@ -0,0 +1,31 @@ +using System; + +namespace MediaBrowser.Model.SyncPlay +{ + /// + /// Class QueueItem. + /// + public class SyncPlayQueueItem + { + /// + /// Initializes a new instance of the class. + /// + /// The item identifier. + public SyncPlayQueueItem(Guid itemId) + { + ItemId = itemId; + } + + /// + /// Gets the item identifier. + /// + /// The item identifier. + public Guid ItemId { get; } + + /// + /// Gets the playlist identifier of the item. + /// + /// The playlist identifier of the item. + public Guid PlaylistItemId { get; } = Guid.NewGuid(); + } +} -- cgit v1.2.3 From b5bbb98175e0542d43c01f80c15e8dce04e58b53 Mon Sep 17 00:00:00 2001 From: Cody Robibero Date: Thu, 29 Jun 2023 05:44:36 -0600 Subject: Fix Websocket OpenApi (#9935) * Further split inbound and outbound messages * Fix datatype for inbound start messages * fixes from review --- .../HttpServer/WebSocketConnection.cs | 16 +++++++++-- .../Session/WebSocketController.cs | 4 +-- .../Net/BasePeriodicWebSocketListener.cs | 4 +-- .../Net/IWebSocketConnection.cs | 1 - MediaBrowser.Controller/Net/WebSocketMessage.cs | 6 ---- .../Net/WebSocketMessageInfo.cs | 2 -- .../Inbound/ActivityLogEntryStartMessage.cs | 10 +++---- .../Inbound/ActivityLogEntryStopMessage.cs | 13 +-------- .../Inbound/InboundKeepAliveMessage.cs | 14 +++++++++ .../Inbound/ScheduledTasksInfoStartMessage.cs | 9 +++--- .../Inbound/ScheduledTasksInfoStopMessage.cs | 13 +-------- .../Inbound/SessionsStartMessage.cs | 8 +++--- .../Inbound/SessionsStopMessage.cs | 12 +------- .../WebSocketMessages/InboundWebSocketMessage.cs | 7 ++--- .../InboundWebSocketMessageOfT.cs | 26 +++++++++++++++++ .../Outbound/ActivityLogEntryMessage.cs | 2 +- .../Outbound/ForceKeepAliveMessage.cs | 2 +- .../Outbound/GeneralCommandMessage.cs | 2 +- .../Outbound/LibraryChangedMessage.cs | 2 +- .../Outbound/OutboundKeepAliveMessage.cs | 14 +++++++++ .../Net/WebSocketMessages/Outbound/PlayMessage.cs | 2 +- .../WebSocketMessages/Outbound/PlaystateMessage.cs | 2 +- .../Outbound/PluginInstallationCancelledMessage.cs | 2 +- .../Outbound/PluginInstallationCompletedMessage.cs | 2 +- .../Outbound/PluginInstallationFailedMessage.cs | 2 +- .../Outbound/PluginInstallingMessage.cs | 2 +- .../Outbound/PluginUninstalledMessage.cs | 2 +- .../Outbound/RefreshProgressMessage.cs | 2 +- .../Outbound/RestartRequiredMessage.cs | 2 +- .../Outbound/ScheduledTaskEndedMessage.cs | 2 +- .../Outbound/ScheduledTasksInfoMessage.cs | 2 +- .../Outbound/SeriesTimerCancelledMessage.cs | 2 +- .../Outbound/SeriesTimerCreatedMessage.cs | 2 +- .../Outbound/ServerRestartingMessage.cs | 2 +- .../Outbound/ServerShuttingDownMessage.cs | 2 +- .../WebSocketMessages/Outbound/SessionsMessage.cs | 5 ++-- .../Outbound/SyncPlayCommandMessage.cs | 2 +- .../Outbound/SyncPlayGroupUpdateCommandMessage.cs | 2 +- ...SyncPlayGroupUpdateCommandOfGroupInfoMessage.cs | 2 +- ...yGroupUpdateCommandOfGroupStateUpdateMessage.cs | 2 +- ...ayGroupUpdateCommandOfPlayQueueUpdateMessage.cs | 2 +- .../SyncPlayGroupUpdateCommandOfStringMessage.cs | 2 +- .../Outbound/TimerCancelledMessage.cs | 2 +- .../Outbound/TimerCreatedMessage.cs | 2 +- .../Outbound/UserDataChangedMessage.cs | 2 +- .../Outbound/UserDeletedMessage.cs | 2 +- .../Outbound/UserUpdatedMessage.cs | 2 +- .../WebSocketMessages/OutboundWebSocketMessage.cs | 11 ++++++-- .../OutboundWebSocketMessageOfT.cs | 33 ++++++++++++++++++++++ .../WebSocketMessages/Shared/KeepAliveMessage.cs | 23 --------------- 50 files changed, 165 insertions(+), 126 deletions(-) create mode 100644 MediaBrowser.Controller/Net/WebSocketMessages/Inbound/InboundKeepAliveMessage.cs create mode 100644 MediaBrowser.Controller/Net/WebSocketMessages/InboundWebSocketMessageOfT.cs create mode 100644 MediaBrowser.Controller/Net/WebSocketMessages/Outbound/OutboundKeepAliveMessage.cs create mode 100644 MediaBrowser.Controller/Net/WebSocketMessages/OutboundWebSocketMessageOfT.cs delete mode 100644 MediaBrowser.Controller/Net/WebSocketMessages/Shared/KeepAliveMessage.cs (limited to 'MediaBrowser.Controller/Net') diff --git a/Emby.Server.Implementations/HttpServer/WebSocketConnection.cs b/Emby.Server.Implementations/HttpServer/WebSocketConnection.cs index b1a99853ad..af79c18c4e 100644 --- a/Emby.Server.Implementations/HttpServer/WebSocketConnection.cs +++ b/Emby.Server.Implementations/HttpServer/WebSocketConnection.cs @@ -9,7 +9,7 @@ using System.Threading; using System.Threading.Tasks; using Jellyfin.Extensions.Json; using MediaBrowser.Controller.Net; -using MediaBrowser.Model.Net; +using MediaBrowser.Controller.Net.WebSocketMessages; using MediaBrowser.Model.Session; using Microsoft.Extensions.Logging; @@ -85,6 +85,18 @@ namespace Emby.Server.Implementations.HttpServer /// The state. public WebSocketState State => _socket.State; + /// + /// Sends a message asynchronously. + /// + /// The message. + /// The cancellation token. + /// Task. + public Task SendAsync(WebSocketMessage message, CancellationToken cancellationToken) + { + var json = JsonSerializer.SerializeToUtf8Bytes(message, _jsonOptions); + return _socket.SendAsync(json, WebSocketMessageType.Text, true, cancellationToken); + } + /// /// Sends a message asynchronously. /// @@ -224,7 +236,7 @@ namespace Emby.Server.Implementations.HttpServer { LastKeepAliveDate = DateTime.UtcNow; return SendAsync( - new WebSocketMessage + new OutboundWebSocketMessage { MessageId = Guid.NewGuid(), MessageType = SessionMessageType.KeepAlive diff --git a/Emby.Server.Implementations/Session/WebSocketController.cs b/Emby.Server.Implementations/Session/WebSocketController.cs index cdc736950e..cf8e0fb006 100644 --- a/Emby.Server.Implementations/Session/WebSocketController.cs +++ b/Emby.Server.Implementations/Session/WebSocketController.cs @@ -7,8 +7,8 @@ using System.Net.WebSockets; using System.Threading; using System.Threading.Tasks; using MediaBrowser.Controller.Net; +using MediaBrowser.Controller.Net.WebSocketMessages; using MediaBrowser.Controller.Session; -using MediaBrowser.Model.Net; using MediaBrowser.Model.Session; using Microsoft.Extensions.Logging; @@ -77,7 +77,7 @@ namespace Emby.Server.Implementations.Session } return socket.SendAsync( - new WebSocketMessage + new OutboundWebSocketMessage { Data = data, MessageType = name, diff --git a/MediaBrowser.Controller/Net/BasePeriodicWebSocketListener.cs b/MediaBrowser.Controller/Net/BasePeriodicWebSocketListener.cs index 0524999c79..a07d9b3eb4 100644 --- a/MediaBrowser.Controller/Net/BasePeriodicWebSocketListener.cs +++ b/MediaBrowser.Controller/Net/BasePeriodicWebSocketListener.cs @@ -9,7 +9,7 @@ using System.Linq; using System.Net.WebSockets; using System.Threading; using System.Threading.Tasks; -using MediaBrowser.Model.Net; +using MediaBrowser.Controller.Net.WebSocketMessages; using MediaBrowser.Model.Session; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Logging; @@ -169,7 +169,7 @@ namespace MediaBrowser.Controller.Net if (data is not null) { await connection.SendAsync( - new WebSocketMessage + new OutboundWebSocketMessage { MessageId = Guid.NewGuid(), MessageType = Type, diff --git a/MediaBrowser.Controller/Net/IWebSocketConnection.cs b/MediaBrowser.Controller/Net/IWebSocketConnection.cs index 4f2492b891..04b333230d 100644 --- a/MediaBrowser.Controller/Net/IWebSocketConnection.cs +++ b/MediaBrowser.Controller/Net/IWebSocketConnection.cs @@ -5,7 +5,6 @@ using System.Net; using System.Net.WebSockets; using System.Threading; using System.Threading.Tasks; -using MediaBrowser.Model.Net; namespace MediaBrowser.Controller.Net { diff --git a/MediaBrowser.Controller/Net/WebSocketMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessage.cs index c02bcd70b6..92183e7929 100644 --- a/MediaBrowser.Controller/Net/WebSocketMessage.cs +++ b/MediaBrowser.Controller/Net/WebSocketMessage.cs @@ -1,4 +1,3 @@ -using System; using System.Text.Json.Serialization; using MediaBrowser.Model.Session; @@ -15,11 +14,6 @@ public abstract class WebSocketMessage /// public virtual SessionMessageType MessageType { get; set; } - /// - /// Gets or sets the message id. - /// - public Guid MessageId { get; set; } - /// /// Gets or sets the server id. /// diff --git a/MediaBrowser.Controller/Net/WebSocketMessageInfo.cs b/MediaBrowser.Controller/Net/WebSocketMessageInfo.cs index 6f7ebf1565..2d986b7b34 100644 --- a/MediaBrowser.Controller/Net/WebSocketMessageInfo.cs +++ b/MediaBrowser.Controller/Net/WebSocketMessageInfo.cs @@ -1,7 +1,5 @@ #nullable disable -using MediaBrowser.Model.Net; - namespace MediaBrowser.Controller.Net { /// diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Inbound/ActivityLogEntryStartMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Inbound/ActivityLogEntryStartMessage.cs index b9f71b9225..b3a60199a9 100644 --- a/MediaBrowser.Controller/Net/WebSocketMessages/Inbound/ActivityLogEntryStartMessage.cs +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Inbound/ActivityLogEntryStartMessage.cs @@ -1,20 +1,20 @@ -using System.Collections.Generic; using System.ComponentModel; -using MediaBrowser.Model.Activity; using MediaBrowser.Model.Session; namespace MediaBrowser.Controller.Net.WebSocketMessages.Inbound; /// /// Activity log entry start message. +/// Data is the timing data encoded as "$initialDelay,$interval" in ms. /// -public class ActivityLogEntryStartMessage : WebSocketMessage>, IInboundWebSocketMessage +public class ActivityLogEntryStartMessage : InboundWebSocketMessage { /// /// Initializes a new instance of the class. + /// Data is the timing data encoded as "$initialDelay,$interval" in ms. /// - /// Collection of activity log entries. - public ActivityLogEntryStartMessage(IReadOnlyCollection data) + /// The timing data encoded as "$initialDelay,$interval". + public ActivityLogEntryStartMessage(string data) : base(data) { } diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Inbound/ActivityLogEntryStopMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Inbound/ActivityLogEntryStopMessage.cs index eac129b20a..6f65cb2c77 100644 --- a/MediaBrowser.Controller/Net/WebSocketMessages/Inbound/ActivityLogEntryStopMessage.cs +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Inbound/ActivityLogEntryStopMessage.cs @@ -1,6 +1,4 @@ -using System.Collections.Generic; using System.ComponentModel; -using MediaBrowser.Model.Activity; using MediaBrowser.Model.Session; namespace MediaBrowser.Controller.Net.WebSocketMessages.Inbound; @@ -8,17 +6,8 @@ namespace MediaBrowser.Controller.Net.WebSocketMessages.Inbound; /// /// Activity log entry stop message. /// -public class ActivityLogEntryStopMessage : WebSocketMessage>, IInboundWebSocketMessage +public class ActivityLogEntryStopMessage : InboundWebSocketMessage { - /// - /// Initializes a new instance of the class. - /// - /// Collection of activity log entries. - public ActivityLogEntryStopMessage(IReadOnlyCollection data) - : base(data) - { - } - /// [DefaultValue(SessionMessageType.ActivityLogEntryStop)] public override SessionMessageType MessageType => SessionMessageType.ActivityLogEntryStop; diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Inbound/InboundKeepAliveMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Inbound/InboundKeepAliveMessage.cs new file mode 100644 index 0000000000..fec7cb4e41 --- /dev/null +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Inbound/InboundKeepAliveMessage.cs @@ -0,0 +1,14 @@ +using System.ComponentModel; +using MediaBrowser.Model.Session; + +namespace MediaBrowser.Controller.Net.WebSocketMessages.Inbound; + +/// +/// Keep alive websocket messages. +/// +public class InboundKeepAliveMessage : InboundWebSocketMessage +{ + /// + [DefaultValue(SessionMessageType.KeepAlive)] + public override SessionMessageType MessageType => SessionMessageType.KeepAlive; +} diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Inbound/ScheduledTasksInfoStartMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Inbound/ScheduledTasksInfoStartMessage.cs index dd2a7145e3..bf98470bf2 100644 --- a/MediaBrowser.Controller/Net/WebSocketMessages/Inbound/ScheduledTasksInfoStartMessage.cs +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Inbound/ScheduledTasksInfoStartMessage.cs @@ -1,20 +1,19 @@ -using System.Collections.Generic; using System.ComponentModel; using MediaBrowser.Model.Session; -using MediaBrowser.Model.Tasks; namespace MediaBrowser.Controller.Net.WebSocketMessages.Inbound; /// /// Scheduled tasks info start message. +/// Data is the timing data encoded as "$initialDelay,$interval" in ms. /// -public class ScheduledTasksInfoStartMessage : WebSocketMessage>, IInboundWebSocketMessage +public class ScheduledTasksInfoStartMessage : InboundWebSocketMessage { /// /// Initializes a new instance of the class. /// - /// Collection of task info. - public ScheduledTasksInfoStartMessage(IReadOnlyCollection data) + /// The timing data encoded as $initialDelay,$interval. + public ScheduledTasksInfoStartMessage(string data) : base(data) { } diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Inbound/ScheduledTasksInfoStopMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Inbound/ScheduledTasksInfoStopMessage.cs index 84e1f01667..f36739c70a 100644 --- a/MediaBrowser.Controller/Net/WebSocketMessages/Inbound/ScheduledTasksInfoStopMessage.cs +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Inbound/ScheduledTasksInfoStopMessage.cs @@ -1,24 +1,13 @@ -using System.Collections.Generic; using System.ComponentModel; using MediaBrowser.Model.Session; -using MediaBrowser.Model.Tasks; namespace MediaBrowser.Controller.Net.WebSocketMessages.Inbound; /// /// Scheduled tasks info stop message. /// -public class ScheduledTasksInfoStopMessage : WebSocketMessage>, IInboundWebSocketMessage +public class ScheduledTasksInfoStopMessage : InboundWebSocketMessage { - /// - /// Initializes a new instance of the class. - /// - /// Collection of task info. - public ScheduledTasksInfoStopMessage(IReadOnlyCollection data) - : base(data) - { - } - /// [DefaultValue(SessionMessageType.ScheduledTasksInfoStop)] public override SessionMessageType MessageType => SessionMessageType.ScheduledTasksInfoStop; diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Inbound/SessionsStartMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Inbound/SessionsStartMessage.cs index e35a5dc3ad..a40a0c79ee 100644 --- a/MediaBrowser.Controller/Net/WebSocketMessages/Inbound/SessionsStartMessage.cs +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Inbound/SessionsStartMessage.cs @@ -1,19 +1,19 @@ using System.ComponentModel; -using MediaBrowser.Controller.Session; using MediaBrowser.Model.Session; namespace MediaBrowser.Controller.Net.WebSocketMessages.Inbound; /// /// Sessions start message. +/// Data is the timing data encoded as "$initialDelay,$interval" in ms. /// -public class SessionsStartMessage : WebSocketMessage, IInboundWebSocketMessage +public class SessionsStartMessage : InboundWebSocketMessage { /// /// Initializes a new instance of the class. /// - /// Session info. - public SessionsStartMessage(SessionInfo data) + /// The timing data encoded as $initialDelay,$interval. + public SessionsStartMessage(string data) : base(data) { } diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Inbound/SessionsStopMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Inbound/SessionsStopMessage.cs index 7e3582d640..288d111c5c 100644 --- a/MediaBrowser.Controller/Net/WebSocketMessages/Inbound/SessionsStopMessage.cs +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Inbound/SessionsStopMessage.cs @@ -1,5 +1,4 @@ using System.ComponentModel; -using MediaBrowser.Controller.Session; using MediaBrowser.Model.Session; namespace MediaBrowser.Controller.Net.WebSocketMessages.Inbound; @@ -7,17 +6,8 @@ namespace MediaBrowser.Controller.Net.WebSocketMessages.Inbound; /// /// Sessions stop message. /// -public class SessionsStopMessage : WebSocketMessage, IInboundWebSocketMessage +public class SessionsStopMessage : InboundWebSocketMessage { - /// - /// Initializes a new instance of the class. - /// - /// Session info. - public SessionsStopMessage(SessionInfo data) - : base(data) - { - } - /// [DefaultValue(SessionMessageType.SessionsStop)] public override SessionMessageType MessageType => SessionMessageType.SessionsStop; diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/InboundWebSocketMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/InboundWebSocketMessage.cs index 20ca888e11..8d6e821df8 100644 --- a/MediaBrowser.Controller/Net/WebSocketMessages/InboundWebSocketMessage.cs +++ b/MediaBrowser.Controller/Net/WebSocketMessages/InboundWebSocketMessage.cs @@ -1,9 +1,8 @@ -namespace MediaBrowser.Controller.Net.WebSocketMessages; +namespace MediaBrowser.Controller.Net.WebSocketMessages; /// -/// Class representing the list of outbound websocket message types. -/// Only used in openapi generation. +/// Inbound websocket message. /// -public class InboundWebSocketMessage : WebSocketMessage +public class InboundWebSocketMessage : WebSocketMessage, IInboundWebSocketMessage { } diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/InboundWebSocketMessageOfT.cs b/MediaBrowser.Controller/Net/WebSocketMessages/InboundWebSocketMessageOfT.cs new file mode 100644 index 0000000000..4da5e7d31f --- /dev/null +++ b/MediaBrowser.Controller/Net/WebSocketMessages/InboundWebSocketMessageOfT.cs @@ -0,0 +1,26 @@ +#pragma warning disable SA1649 // File name must equal class name. + +namespace MediaBrowser.Controller.Net.WebSocketMessages; + +/// +/// Inbound websocket message with data. +/// +/// The data type. +public class InboundWebSocketMessage : WebSocketMessage, IInboundWebSocketMessage +{ + /// + /// Initializes a new instance of the class. + /// + public InboundWebSocketMessage() + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The data to send. + protected InboundWebSocketMessage(T data) + { + Data = data; + } +} diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/ActivityLogEntryMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/ActivityLogEntryMessage.cs index 5650ee4bbe..2a098615d5 100644 --- a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/ActivityLogEntryMessage.cs +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/ActivityLogEntryMessage.cs @@ -8,7 +8,7 @@ namespace MediaBrowser.Controller.Net.WebSocketMessages.Outbound; /// /// Activity log created message. /// -public class ActivityLogEntryMessage : WebSocketMessage>, IOutboundWebSocketMessage +public class ActivityLogEntryMessage : OutboundWebSocketMessage> { /// /// Initializes a new instance of the class. diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/ForceKeepAliveMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/ForceKeepAliveMessage.cs index 94ade5e817..ca55340a05 100644 --- a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/ForceKeepAliveMessage.cs +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/ForceKeepAliveMessage.cs @@ -6,7 +6,7 @@ namespace MediaBrowser.Controller.Net.WebSocketMessages.Outbound; /// /// Force keep alive websocket messages. /// -public class ForceKeepAliveMessage : WebSocketMessage, IOutboundWebSocketMessage +public class ForceKeepAliveMessage : OutboundWebSocketMessage { /// /// Initializes a new instance of the class. diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/GeneralCommandMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/GeneralCommandMessage.cs index 6c71e73f9d..5fbbb06242 100644 --- a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/GeneralCommandMessage.cs +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/GeneralCommandMessage.cs @@ -6,7 +6,7 @@ namespace MediaBrowser.Controller.Net.WebSocketMessages.Outbound; /// /// General command websocket message. /// -public class GeneralCommandMessage : WebSocketMessage, IOutboundWebSocketMessage +public class GeneralCommandMessage : OutboundWebSocketMessage { /// /// Initializes a new instance of the class. diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/LibraryChangedMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/LibraryChangedMessage.cs index 6432ae8efb..47417c4059 100644 --- a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/LibraryChangedMessage.cs +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/LibraryChangedMessage.cs @@ -7,7 +7,7 @@ namespace MediaBrowser.Controller.Net.WebSocketMessages.Outbound; /// /// Library changed message. /// -public class LibraryChangedMessage : WebSocketMessage, IOutboundWebSocketMessage +public class LibraryChangedMessage : OutboundWebSocketMessage { /// /// Initializes a new instance of the class. diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/OutboundKeepAliveMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/OutboundKeepAliveMessage.cs new file mode 100644 index 0000000000..d907dcff95 --- /dev/null +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/OutboundKeepAliveMessage.cs @@ -0,0 +1,14 @@ +using System.ComponentModel; +using MediaBrowser.Model.Session; + +namespace MediaBrowser.Controller.Net.WebSocketMessages.Outbound; + +/// +/// Keep alive websocket messages. +/// +public class OutboundKeepAliveMessage : OutboundWebSocketMessage +{ + /// + [DefaultValue(SessionMessageType.KeepAlive)] + public override SessionMessageType MessageType => SessionMessageType.KeepAlive; +} diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/PlayMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/PlayMessage.cs index 7f943bda10..86ee2ff900 100644 --- a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/PlayMessage.cs +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/PlayMessage.cs @@ -6,7 +6,7 @@ namespace MediaBrowser.Controller.Net.WebSocketMessages.Outbound; /// /// Play command websocket message. /// -public class PlayMessage : WebSocketMessage, IOutboundWebSocketMessage +public class PlayMessage : OutboundWebSocketMessage { /// /// Initializes a new instance of the class. diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/PlaystateMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/PlaystateMessage.cs index 804ccb37d6..cd6d28cb30 100644 --- a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/PlaystateMessage.cs +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/PlaystateMessage.cs @@ -6,7 +6,7 @@ namespace MediaBrowser.Controller.Net.WebSocketMessages.Outbound; /// /// Playstate message. /// -public class PlaystateMessage : WebSocketMessage, IOutboundWebSocketMessage +public class PlaystateMessage : OutboundWebSocketMessage { /// /// Initializes a new instance of the class. diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/PluginInstallationCancelledMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/PluginInstallationCancelledMessage.cs index 3d7dc5c937..17fd259384 100644 --- a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/PluginInstallationCancelledMessage.cs +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/PluginInstallationCancelledMessage.cs @@ -7,7 +7,7 @@ namespace MediaBrowser.Controller.Net.WebSocketMessages.Outbound; /// /// Plugin installation cancelled message. /// -public class PluginInstallationCancelledMessage : WebSocketMessage, IOutboundWebSocketMessage +public class PluginInstallationCancelledMessage : OutboundWebSocketMessage { /// /// Initializes a new instance of the class. diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/PluginInstallationCompletedMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/PluginInstallationCompletedMessage.cs index 81268007fd..3e60198bac 100644 --- a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/PluginInstallationCompletedMessage.cs +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/PluginInstallationCompletedMessage.cs @@ -7,7 +7,7 @@ namespace MediaBrowser.Controller.Net.WebSocketMessages.Outbound; /// /// Plugin installation completed message. /// -public class PluginInstallationCompletedMessage : WebSocketMessage, IOutboundWebSocketMessage +public class PluginInstallationCompletedMessage : OutboundWebSocketMessage { /// /// Initializes a new instance of the class. diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/PluginInstallationFailedMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/PluginInstallationFailedMessage.cs index 9177f12938..40032f16e4 100644 --- a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/PluginInstallationFailedMessage.cs +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/PluginInstallationFailedMessage.cs @@ -7,7 +7,7 @@ namespace MediaBrowser.Controller.Net.WebSocketMessages.Outbound; /// /// Plugin installation failed message. /// -public class PluginInstallationFailedMessage : WebSocketMessage, IOutboundWebSocketMessage +public class PluginInstallationFailedMessage : OutboundWebSocketMessage { /// /// Initializes a new instance of the class. diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/PluginInstallingMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/PluginInstallingMessage.cs index e371440a0f..28861896f7 100644 --- a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/PluginInstallingMessage.cs +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/PluginInstallingMessage.cs @@ -7,7 +7,7 @@ namespace MediaBrowser.Controller.Net.WebSocketMessages.Outbound; /// /// Package installing message. /// -public class PluginInstallingMessage : WebSocketMessage, IOutboundWebSocketMessage +public class PluginInstallingMessage : OutboundWebSocketMessage { /// /// Initializes a new instance of the class. diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/PluginUninstalledMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/PluginUninstalledMessage.cs index b2994fc956..ca49591194 100644 --- a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/PluginUninstalledMessage.cs +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/PluginUninstalledMessage.cs @@ -7,7 +7,7 @@ namespace MediaBrowser.Controller.Net.WebSocketMessages.Outbound; /// /// Plugin uninstalled message. /// -public class PluginUninstalledMessage : WebSocketMessage, IOutboundWebSocketMessage +public class PluginUninstalledMessage : OutboundWebSocketMessage { /// /// Initializes a new instance of the class. diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/RefreshProgressMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/RefreshProgressMessage.cs index 42dbc30295..41b3cd46ab 100644 --- a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/RefreshProgressMessage.cs +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/RefreshProgressMessage.cs @@ -7,7 +7,7 @@ namespace MediaBrowser.Controller.Net.WebSocketMessages.Outbound; /// /// Refresh progress message. /// -public class RefreshProgressMessage : WebSocketMessage>, IOutboundWebSocketMessage +public class RefreshProgressMessage : OutboundWebSocketMessage> { /// /// Initializes a new instance of the class. diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/RestartRequiredMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/RestartRequiredMessage.cs index 3f3d9e4c84..a89f19b617 100644 --- a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/RestartRequiredMessage.cs +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/RestartRequiredMessage.cs @@ -6,7 +6,7 @@ namespace MediaBrowser.Controller.Net.WebSocketMessages.Outbound; /// /// Restart required. /// -public class RestartRequiredMessage : WebSocketMessage, IOutboundWebSocketMessage +public class RestartRequiredMessage : OutboundWebSocketMessage { /// [DefaultValue(SessionMessageType.RestartRequired)] diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/ScheduledTaskEndedMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/ScheduledTaskEndedMessage.cs index d69662b004..afa36fb722 100644 --- a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/ScheduledTaskEndedMessage.cs +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/ScheduledTaskEndedMessage.cs @@ -7,7 +7,7 @@ namespace MediaBrowser.Controller.Net.WebSocketMessages.Outbound; /// /// Scheduled task ended message. /// -public class ScheduledTaskEndedMessage : WebSocketMessage, IOutboundWebSocketMessage +public class ScheduledTaskEndedMessage : OutboundWebSocketMessage { /// /// Initializes a new instance of the class. diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/ScheduledTasksInfoMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/ScheduledTasksInfoMessage.cs index 41a05b0de2..c7360779f9 100644 --- a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/ScheduledTasksInfoMessage.cs +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/ScheduledTasksInfoMessage.cs @@ -8,7 +8,7 @@ namespace MediaBrowser.Controller.Net.WebSocketMessages.Outbound; /// /// Scheduled tasks info message. /// -public class ScheduledTasksInfoMessage : WebSocketMessage>, IOutboundWebSocketMessage +public class ScheduledTasksInfoMessage : OutboundWebSocketMessage> { /// /// Initializes a new instance of the class. diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/SeriesTimerCancelledMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/SeriesTimerCancelledMessage.cs index d4950b8b67..f832c8935e 100644 --- a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/SeriesTimerCancelledMessage.cs +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/SeriesTimerCancelledMessage.cs @@ -7,7 +7,7 @@ namespace MediaBrowser.Controller.Net.WebSocketMessages.Outbound; /// /// Series timer cancelled message. /// -public class SeriesTimerCancelledMessage : WebSocketMessage, IOutboundWebSocketMessage +public class SeriesTimerCancelledMessage : OutboundWebSocketMessage { /// /// Initializes a new instance of the class. diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/SeriesTimerCreatedMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/SeriesTimerCreatedMessage.cs index 091c10be6d..450b4c7994 100644 --- a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/SeriesTimerCreatedMessage.cs +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/SeriesTimerCreatedMessage.cs @@ -7,7 +7,7 @@ namespace MediaBrowser.Controller.Net.WebSocketMessages.Outbound; /// /// Series timer created message. /// -public class SeriesTimerCreatedMessage : WebSocketMessage, IOutboundWebSocketMessage +public class SeriesTimerCreatedMessage : OutboundWebSocketMessage { /// /// Initializes a new instance of the class. diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/ServerRestartingMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/ServerRestartingMessage.cs index a465d8b008..8f09c802fe 100644 --- a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/ServerRestartingMessage.cs +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/ServerRestartingMessage.cs @@ -6,7 +6,7 @@ namespace MediaBrowser.Controller.Net.WebSocketMessages.Outbound; /// /// Server restarting down message. /// -public class ServerRestartingMessage : WebSocketMessage, IOutboundWebSocketMessage +public class ServerRestartingMessage : OutboundWebSocketMessage { /// [DefaultValue(SessionMessageType.ServerRestarting)] diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/ServerShuttingDownMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/ServerShuttingDownMessage.cs index 0b998a5239..485e71b6e3 100644 --- a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/ServerShuttingDownMessage.cs +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/ServerShuttingDownMessage.cs @@ -6,7 +6,7 @@ namespace MediaBrowser.Controller.Net.WebSocketMessages.Outbound; /// /// Server shutting down message. /// -public class ServerShuttingDownMessage : WebSocketMessage, IOutboundWebSocketMessage +public class ServerShuttingDownMessage : OutboundWebSocketMessage { /// [DefaultValue(SessionMessageType.ServerShuttingDown)] diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/SessionsMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/SessionsMessage.cs index 4c91e0bca2..3504831b87 100644 --- a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/SessionsMessage.cs +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/SessionsMessage.cs @@ -1,3 +1,4 @@ +using System.Collections.Generic; using System.ComponentModel; using MediaBrowser.Controller.Session; using MediaBrowser.Model.Session; @@ -7,13 +8,13 @@ namespace MediaBrowser.Controller.Net.WebSocketMessages.Outbound; /// /// Sessions message. /// -public class SessionsMessage : WebSocketMessage, IOutboundWebSocketMessage +public class SessionsMessage : OutboundWebSocketMessage> { /// /// Initializes a new instance of the class. /// /// Session info. - public SessionsMessage(SessionInfo data) + public SessionsMessage(IReadOnlyList data) : base(data) { } diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/SyncPlayCommandMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/SyncPlayCommandMessage.cs index 17a0fc66e5..d0624ec016 100644 --- a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/SyncPlayCommandMessage.cs +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/SyncPlayCommandMessage.cs @@ -7,7 +7,7 @@ namespace MediaBrowser.Controller.Net.WebSocketMessages.Outbound; /// /// Sync play command. /// -public class SyncPlayCommandMessage : WebSocketMessage, IOutboundWebSocketMessage +public class SyncPlayCommandMessage : OutboundWebSocketMessage { /// /// Initializes a new instance of the class. diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/SyncPlayGroupUpdateCommandMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/SyncPlayGroupUpdateCommandMessage.cs index d145d0e01a..6a501aa7ea 100644 --- a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/SyncPlayGroupUpdateCommandMessage.cs +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/SyncPlayGroupUpdateCommandMessage.cs @@ -7,7 +7,7 @@ namespace MediaBrowser.Controller.Net.WebSocketMessages.Outbound; /// /// Untyped sync play command. /// -public class SyncPlayGroupUpdateCommandMessage : WebSocketMessage, IOutboundWebSocketMessage +public class SyncPlayGroupUpdateCommandMessage : OutboundWebSocketMessage { /// /// Initializes a new instance of the class. diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/SyncPlayGroupUpdateCommandOfGroupInfoMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/SyncPlayGroupUpdateCommandOfGroupInfoMessage.cs index 668392c66b..47f706e2a4 100644 --- a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/SyncPlayGroupUpdateCommandOfGroupInfoMessage.cs +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/SyncPlayGroupUpdateCommandOfGroupInfoMessage.cs @@ -8,7 +8,7 @@ namespace MediaBrowser.Controller.Net.WebSocketMessages.Outbound; /// Sync play group update command with group info. /// GroupUpdateTypes: GroupJoined. /// -public class SyncPlayGroupUpdateCommandOfGroupInfoMessage : WebSocketMessage>, IOutboundWebSocketMessage +public class SyncPlayGroupUpdateCommandOfGroupInfoMessage : OutboundWebSocketMessage> { /// /// Initializes a new instance of the class. diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/SyncPlayGroupUpdateCommandOfGroupStateUpdateMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/SyncPlayGroupUpdateCommandOfGroupStateUpdateMessage.cs index ec8c3344f4..11ddb1e250 100644 --- a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/SyncPlayGroupUpdateCommandOfGroupStateUpdateMessage.cs +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/SyncPlayGroupUpdateCommandOfGroupStateUpdateMessage.cs @@ -8,7 +8,7 @@ namespace MediaBrowser.Controller.Net.WebSocketMessages.Outbound; /// Sync play group update command with group state update. /// GroupUpdateTypes: StateUpdate. /// -public class SyncPlayGroupUpdateCommandOfGroupStateUpdateMessage : WebSocketMessage>, IOutboundWebSocketMessage +public class SyncPlayGroupUpdateCommandOfGroupStateUpdateMessage : OutboundWebSocketMessage> { /// /// Initializes a new instance of the class. diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/SyncPlayGroupUpdateCommandOfPlayQueueUpdateMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/SyncPlayGroupUpdateCommandOfPlayQueueUpdateMessage.cs index 465363f143..7e73399b1b 100644 --- a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/SyncPlayGroupUpdateCommandOfPlayQueueUpdateMessage.cs +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/SyncPlayGroupUpdateCommandOfPlayQueueUpdateMessage.cs @@ -8,7 +8,7 @@ namespace MediaBrowser.Controller.Net.WebSocketMessages.Outbound; /// Sync play group update command with play queue update. /// GroupUpdateTypes: PlayQueue. /// -public class SyncPlayGroupUpdateCommandOfPlayQueueUpdateMessage : WebSocketMessage>, IOutboundWebSocketMessage +public class SyncPlayGroupUpdateCommandOfPlayQueueUpdateMessage : OutboundWebSocketMessage> { /// /// Initializes a new instance of the class. diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/SyncPlayGroupUpdateCommandOfStringMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/SyncPlayGroupUpdateCommandOfStringMessage.cs index b87e9bf715..5b5ccd3eda 100644 --- a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/SyncPlayGroupUpdateCommandOfStringMessage.cs +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/SyncPlayGroupUpdateCommandOfStringMessage.cs @@ -8,7 +8,7 @@ namespace MediaBrowser.Controller.Net.WebSocketMessages.Outbound; /// Sync play group update command with string. /// GroupUpdateTypes: GroupDoesNotExist (error), LibraryAccessDenied (error), NotInGroup (error), GroupLeft (groupId), UserJoined (username), UserLeft (username). /// -public class SyncPlayGroupUpdateCommandOfStringMessage : WebSocketMessage>, IOutboundWebSocketMessage +public class SyncPlayGroupUpdateCommandOfStringMessage : OutboundWebSocketMessage> { /// /// Initializes a new instance of the class. diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/TimerCancelledMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/TimerCancelledMessage.cs index 0e70549ef8..f44fd126b6 100644 --- a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/TimerCancelledMessage.cs +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/TimerCancelledMessage.cs @@ -7,7 +7,7 @@ namespace MediaBrowser.Controller.Net.WebSocketMessages.Outbound; /// /// Timer cancelled message. /// -public class TimerCancelledMessage : WebSocketMessage, IOutboundWebSocketMessage +public class TimerCancelledMessage : OutboundWebSocketMessage { /// /// Initializes a new instance of the class. diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/TimerCreatedMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/TimerCreatedMessage.cs index 295b3081ce..8c1e102eb2 100644 --- a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/TimerCreatedMessage.cs +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/TimerCreatedMessage.cs @@ -7,7 +7,7 @@ namespace MediaBrowser.Controller.Net.WebSocketMessages.Outbound; /// /// Timer created message. /// -public class TimerCreatedMessage : WebSocketMessage, IOutboundWebSocketMessage +public class TimerCreatedMessage : OutboundWebSocketMessage { /// /// Initializes a new instance of the class. diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/UserDataChangedMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/UserDataChangedMessage.cs index b60769540d..6a053643d8 100644 --- a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/UserDataChangedMessage.cs +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/UserDataChangedMessage.cs @@ -6,7 +6,7 @@ namespace MediaBrowser.Controller.Net.WebSocketMessages.Outbound; /// /// User data changed message. /// -public class UserDataChangedMessage : WebSocketMessage, IOutboundWebSocketMessage +public class UserDataChangedMessage : OutboundWebSocketMessage { /// /// Initializes a new instance of the class. diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/UserDeletedMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/UserDeletedMessage.cs index 6d527be7f2..add3f77717 100644 --- a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/UserDeletedMessage.cs +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/UserDeletedMessage.cs @@ -7,7 +7,7 @@ namespace MediaBrowser.Controller.Net.WebSocketMessages.Outbound; /// /// User deleted message. /// -public class UserDeletedMessage : WebSocketMessage, IOutboundWebSocketMessage +public class UserDeletedMessage : OutboundWebSocketMessage { /// /// Initializes a new instance of the class. diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/UserUpdatedMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/UserUpdatedMessage.cs index 99e9a1f911..9a72deae1f 100644 --- a/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/UserUpdatedMessage.cs +++ b/MediaBrowser.Controller/Net/WebSocketMessages/Outbound/UserUpdatedMessage.cs @@ -7,7 +7,7 @@ namespace MediaBrowser.Controller.Net.WebSocketMessages.Outbound; /// /// User updated message. /// -public class UserUpdatedMessage : WebSocketMessage, IOutboundWebSocketMessage +public class UserUpdatedMessage : OutboundWebSocketMessage { /// /// Initializes a new instance of the class. diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/OutboundWebSocketMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/OutboundWebSocketMessage.cs index dba3c8392b..ad97796e70 100644 --- a/MediaBrowser.Controller/Net/WebSocketMessages/OutboundWebSocketMessage.cs +++ b/MediaBrowser.Controller/Net/WebSocketMessages/OutboundWebSocketMessage.cs @@ -1,9 +1,14 @@ +using System; + namespace MediaBrowser.Controller.Net.WebSocketMessages; /// -/// Class representing the list of outbound websocket message types. -/// Only used in openapi generation. +/// Outbound websocket message. /// -public class OutboundWebSocketMessage : WebSocketMessage +public class OutboundWebSocketMessage : WebSocketMessage, IOutboundWebSocketMessage { + /// + /// Gets or sets the message id. + /// + public Guid MessageId { get; set; } } diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/OutboundWebSocketMessageOfT.cs b/MediaBrowser.Controller/Net/WebSocketMessages/OutboundWebSocketMessageOfT.cs new file mode 100644 index 0000000000..f09f294b41 --- /dev/null +++ b/MediaBrowser.Controller/Net/WebSocketMessages/OutboundWebSocketMessageOfT.cs @@ -0,0 +1,33 @@ +#pragma warning disable SA1649 // File name must equal class name. + +using System; + +namespace MediaBrowser.Controller.Net.WebSocketMessages; + +/// +/// Outbound websocket message with data. +/// +/// The data type. +public class OutboundWebSocketMessage : WebSocketMessage, IOutboundWebSocketMessage +{ + /// + /// Initializes a new instance of the class. + /// + public OutboundWebSocketMessage() + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The data to send. + protected OutboundWebSocketMessage(T data) + { + Data = data; + } + + /// + /// Gets or sets the message id. + /// + public Guid MessageId { get; set; } +} diff --git a/MediaBrowser.Controller/Net/WebSocketMessages/Shared/KeepAliveMessage.cs b/MediaBrowser.Controller/Net/WebSocketMessages/Shared/KeepAliveMessage.cs deleted file mode 100644 index 7f636212ca..0000000000 --- a/MediaBrowser.Controller/Net/WebSocketMessages/Shared/KeepAliveMessage.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.ComponentModel; -using MediaBrowser.Model.Session; - -namespace MediaBrowser.Controller.Net.WebSocketMessages.Shared; - -/// -/// Keep alive websocket messages. -/// -public class KeepAliveMessage : WebSocketMessage, IInboundWebSocketMessage, IOutboundWebSocketMessage -{ - /// - /// Initializes a new instance of the class. - /// - /// The seconds to keep alive for. - public KeepAliveMessage(int data) - : base(data) - { - } - - /// - [DefaultValue(SessionMessageType.KeepAlive)] - public override SessionMessageType MessageType => SessionMessageType.KeepAlive; -} -- cgit v1.2.3