From 9a0dfc00f1e36092476f62984ba66886032f4f89 Mon Sep 17 00:00:00 2001 From: Cody Robibero Date: Sat, 10 Jun 2023 07:28:21 -0600 Subject: [PATCH] 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 --- .../Filters/AdditionalModelFilter.cs | 148 ++++++++++++++++-- .../Net/WebSocketMessage.cs | 28 ++++ .../Net/WebSocketMessageOfT.cs | 33 ++++ .../IInboundWebSocketMessage.cs | 10 ++ .../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 +++ .../InboundWebSocketMessage.cs | 9 ++ .../Outbound/ActivityLogEntryMessage.cs | 25 +++ .../Outbound/ForceKeepAliveMessage.cs | 23 +++ .../Outbound/GeneralCommandMessage.cs | 23 +++ .../Outbound/LibraryChangedMessage.cs | 24 +++ .../WebSocketMessages/Outbound/PlayMessage.cs | 23 +++ .../Outbound/PlaystateMessage.cs | 23 +++ .../PluginInstallationCancelledMessage.cs | 24 +++ .../PluginInstallationCompletedMessage.cs | 24 +++ .../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 ++ .../Outbound/SessionsMessage.cs | 24 +++ .../Outbound/SyncPlayCommandMessage.cs | 24 +++ .../SyncPlayGroupUpdateCommandMessage.cs | 24 +++ ...layGroupUpdateCommandOfGroupInfoMessage.cs | 25 +++ ...pUpdateCommandOfGroupStateUpdateMessage.cs | 25 +++ ...upUpdateCommandOfPlayQueueUpdateMessage.cs | 25 +++ ...ncPlayGroupUpdateCommandOfStringMessage.cs | 25 +++ .../Outbound/TimerCancelledMessage.cs | 24 +++ .../Outbound/TimerCreatedMessage.cs | 24 +++ .../Outbound/UserDataChangedMessage.cs | 23 +++ .../Outbound/UserDeletedMessage.cs | 24 +++ .../Outbound/UserUpdatedMessage.cs | 24 +++ .../OutboundWebSocketMessage.cs | 9 ++ .../Shared/KeepAliveMessage.cs | 23 +++ .../SyncPlay/Queue/PlayQueueManager.cs | 24 +-- MediaBrowser.Model/Net/WebSocketMessage.cs | 31 ---- MediaBrowser.Model/SyncPlay/GroupUpdate.cs | 56 +++---- MediaBrowser.Model/SyncPlay/GroupUpdateOfT.cs | 31 ++++ .../SyncPlay/PlayQueueUpdate.cs | 4 +- .../{QueueItem.cs => SyncPlayQueueItem.cs} | 6 +- 51 files changed, 1193 insertions(+), 92 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 rename MediaBrowser.Model/SyncPlay/{QueueItem.cs => SyncPlayQueueItem.cs} (80%) 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; } - - /// - /// Gets the update type. - /// - /// The update type. - public GroupUpdateType Type { get; } - - /// - /// Gets the update data. - /// - /// The update data. - public T Data { get; } + GroupId = groupId; } + + /// + /// Gets the group identifier. + /// + /// The group identifier. + public Guid GroupId { 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/SyncPlayQueueItem.cs similarity index 80% rename from MediaBrowser.Model/SyncPlay/QueueItem.cs rename to MediaBrowser.Model/SyncPlay/SyncPlayQueueItem.cs index a6dcc109ed..da81fecbdc 100644 --- a/MediaBrowser.Model/SyncPlay/QueueItem.cs +++ b/MediaBrowser.Model/SyncPlay/SyncPlayQueueItem.cs @@ -5,13 +5,13 @@ namespace MediaBrowser.Model.SyncPlay /// /// Class QueueItem. /// - public class QueueItem + public class SyncPlayQueueItem { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The item identifier. - public QueueItem(Guid itemId) + public SyncPlayQueueItem(Guid itemId) { ItemId = itemId; }