diff options
| author | Ionut Andrei Oanca <oancaionutandrei@gmail.com> | 2020-11-15 17:03:27 +0100 |
|---|---|---|
| committer | Ionut Andrei Oanca <oancaionutandrei@gmail.com> | 2020-11-15 17:30:28 +0100 |
| commit | c7e53bce2fa43ad38807a0589e1bc020237e49c6 (patch) | |
| tree | af484c31dc4b762aba404a28462a3cae8c23f5b5 /MediaBrowser.Model | |
| parent | 5d77f422f0e4998130f1defebd08e053188a1a25 (diff) | |
Patch data-races and minor changes in SyncPlay
Diffstat (limited to 'MediaBrowser.Model')
| -rw-r--r-- | MediaBrowser.Model/SyncPlay/GroupInfoDto.cs | 37 | ||||
| -rw-r--r-- | MediaBrowser.Model/SyncPlay/GroupStateUpdate.cs | 19 | ||||
| -rw-r--r-- | MediaBrowser.Model/SyncPlay/GroupUpdate.cs | 29 | ||||
| -rw-r--r-- | MediaBrowser.Model/SyncPlay/JoinGroupRequest.cs | 13 | ||||
| -rw-r--r-- | MediaBrowser.Model/SyncPlay/NewGroupRequest.cs | 9 | ||||
| -rw-r--r-- | MediaBrowser.Model/SyncPlay/PlayQueueUpdate.cs | 45 | ||||
| -rw-r--r-- | MediaBrowser.Model/SyncPlay/SendCommand.cs | 36 | ||||
| -rw-r--r-- | MediaBrowser.Model/SyncPlay/UtcTimeResponse.cs | 21 |
8 files changed, 142 insertions, 67 deletions
diff --git a/MediaBrowser.Model/SyncPlay/GroupInfoDto.cs b/MediaBrowser.Model/SyncPlay/GroupInfoDto.cs index 16a75eb68..8c0960b83 100644 --- a/MediaBrowser.Model/SyncPlay/GroupInfoDto.cs +++ b/MediaBrowser.Model/SyncPlay/GroupInfoDto.cs @@ -11,41 +11,48 @@ namespace MediaBrowser.Model.SyncPlay /// <summary> /// Initializes a new instance of the <see cref="GroupInfoDto"/> class. /// </summary> - public GroupInfoDto() + /// <param name="groupId">The group identifier.</param> + /// <param name="groupName">The group name.</param> + /// <param name="state">The group state.</param> + /// <param name="participants">The participants.</param> + /// <param name="lastUpdatedAt">The date when this DTO has been created.</param> + public GroupInfoDto(Guid groupId, string groupName, GroupStateType state, IReadOnlyList<string> participants, DateTime lastUpdatedAt) { - GroupId = string.Empty; - GroupName = string.Empty; - Participants = new List<string>(); + GroupId = groupId; + GroupName = groupName; + State = state; + Participants = participants; + LastUpdatedAt = lastUpdatedAt; } /// <summary> - /// Gets or sets the group identifier. + /// Gets the group identifier. /// </summary> /// <value>The group identifier.</value> - public string GroupId { get; set; } + public Guid GroupId { get; } /// <summary> - /// Gets or sets the group name. + /// Gets the group name. /// </summary> /// <value>The group name.</value> - public string GroupName { get; set; } + public string GroupName { get; } /// <summary> - /// Gets or sets the group state. + /// Gets the group state. /// </summary> /// <value>The group state.</value> - public GroupStateType State { get; set; } + public GroupStateType State { get; } /// <summary> - /// Gets or sets the participants. + /// Gets the participants. /// </summary> /// <value>The participants.</value> - public IReadOnlyList<string> Participants { get; set; } + public IReadOnlyList<string> Participants { get; } /// <summary> - /// Gets or sets the date when this dto has been updated. + /// Gets the date when this DTO has been created. /// </summary> - /// <value>The date when this dto has been updated.</value> - public DateTime LastUpdatedAt { get; set; } + /// <value>The date when this DTO has been created.</value> + public DateTime LastUpdatedAt { get; } } } diff --git a/MediaBrowser.Model/SyncPlay/GroupStateUpdate.cs b/MediaBrowser.Model/SyncPlay/GroupStateUpdate.cs index 532b5a56f..7f7deb86b 100644 --- a/MediaBrowser.Model/SyncPlay/GroupStateUpdate.cs +++ b/MediaBrowser.Model/SyncPlay/GroupStateUpdate.cs @@ -6,15 +6,26 @@ namespace MediaBrowser.Model.SyncPlay public class GroupStateUpdate { /// <summary> - /// Gets or sets the state of the group. + /// Initializes a new instance of the <see cref="GroupStateUpdate"/> class. + /// </summary> + /// <param name="state">The state of the group.</param> + /// <param name="reason">The reason of the state change.</param> + public GroupStateUpdate(GroupStateType state, PlaybackRequestType reason) + { + State = state; + Reason = reason; + } + + /// <summary> + /// Gets the state of the group. /// </summary> /// <value>The state of the group.</value> - public GroupStateType State { get; set; } + public GroupStateType State { get; } /// <summary> - /// Gets or sets the reason of the state change. + /// Gets the reason of the state change. /// </summary> /// <value>The reason of the state change.</value> - public PlaybackRequestType Reason { get; set; } + public PlaybackRequestType Reason { get; } } } diff --git a/MediaBrowser.Model/SyncPlay/GroupUpdate.cs b/MediaBrowser.Model/SyncPlay/GroupUpdate.cs index 12d6058ac..6f159d653 100644 --- a/MediaBrowser.Model/SyncPlay/GroupUpdate.cs +++ b/MediaBrowser.Model/SyncPlay/GroupUpdate.cs @@ -1,4 +1,4 @@ -#nullable disable +using System; namespace MediaBrowser.Model.SyncPlay { @@ -9,21 +9,34 @@ namespace MediaBrowser.Model.SyncPlay public class GroupUpdate<T> { /// <summary> - /// Gets or sets the group identifier. + /// Initializes a new instance of the <see cref="GroupUpdate{T}"/> class. + /// </summary> + /// <param name="groupId">The group identifier.</param> + /// <param name="type">The update type.</param> + /// <param name="data">The update data.</param> + public GroupUpdate(Guid groupId, GroupUpdateType type, T data) + { + GroupId = groupId; + Type = type; + Data = data; + } + + /// <summary> + /// Gets the group identifier. /// </summary> /// <value>The group identifier.</value> - public string GroupId { get; set; } + public Guid GroupId { get; } /// <summary> - /// Gets or sets the update type. + /// Gets the update type. /// </summary> /// <value>The update type.</value> - public GroupUpdateType Type { get; set; } + public GroupUpdateType Type { get; } /// <summary> - /// Gets or sets the data. + /// Gets the update data. /// </summary> - /// <value>The data.</value> - public T Data { get; set; } + /// <value>The update data.</value> + public T Data { get; } } } diff --git a/MediaBrowser.Model/SyncPlay/JoinGroupRequest.cs b/MediaBrowser.Model/SyncPlay/JoinGroupRequest.cs index 27a29b899..7402c4ce2 100644 --- a/MediaBrowser.Model/SyncPlay/JoinGroupRequest.cs +++ b/MediaBrowser.Model/SyncPlay/JoinGroupRequest.cs @@ -8,9 +8,18 @@ namespace MediaBrowser.Model.SyncPlay public class JoinGroupRequest { /// <summary> - /// Gets or sets the group identifier. + /// Initializes a new instance of the <see cref="JoinGroupRequest"/> class. + /// </summary> + /// <param name="groupId">The identifier of the group to join.</param> + public JoinGroupRequest(Guid groupId) + { + GroupId = groupId; + } + + /// <summary> + /// Gets the group identifier. /// </summary> /// <value>The identifier of the group to join.</value> - public Guid GroupId { get; set; } + public Guid GroupId { get; } } } diff --git a/MediaBrowser.Model/SyncPlay/NewGroupRequest.cs b/MediaBrowser.Model/SyncPlay/NewGroupRequest.cs index eb61a68d1..ba4bd3ef1 100644 --- a/MediaBrowser.Model/SyncPlay/NewGroupRequest.cs +++ b/MediaBrowser.Model/SyncPlay/NewGroupRequest.cs @@ -8,15 +8,16 @@ namespace MediaBrowser.Model.SyncPlay /// <summary> /// Initializes a new instance of the <see cref="NewGroupRequest"/> class. /// </summary> - public NewGroupRequest() + /// <param name="groupName">The name of the new group.</param> + public NewGroupRequest(string groupName) { - GroupName = string.Empty; + GroupName = groupName; } /// <summary> - /// Gets or sets the group name. + /// Gets the group name. /// </summary> /// <value>The name of the new group.</value> - public string GroupName { get; set; } + public string GroupName { get; } } } diff --git a/MediaBrowser.Model/SyncPlay/PlayQueueUpdate.cs b/MediaBrowser.Model/SyncPlay/PlayQueueUpdate.cs index d193b4c66..a851229f7 100644 --- a/MediaBrowser.Model/SyncPlay/PlayQueueUpdate.cs +++ b/MediaBrowser.Model/SyncPlay/PlayQueueUpdate.cs @@ -11,51 +11,64 @@ namespace MediaBrowser.Model.SyncPlay /// <summary> /// Initializes a new instance of the <see cref="PlayQueueUpdate"/> class. /// </summary> - public PlayQueueUpdate() + /// <param name="reason">The reason for the update.</param> + /// <param name="lastUpdate">The UTC time of the last change to the playing queue.</param> + /// <param name="playlist">The playlist.</param> + /// <param name="playingItemIndex">The playing item index in the playlist.</param> + /// <param name="startPositionTicks">The start position ticks.</param> + /// <param name="shuffleMode">The shuffle mode.</param> + /// <param name="repeatMode">The repeat mode.</param> + public PlayQueueUpdate(PlayQueueUpdateReason reason, DateTime lastUpdate, IReadOnlyList<QueueItem> playlist, int playingItemIndex, long startPositionTicks, GroupShuffleMode shuffleMode, GroupRepeatMode repeatMode) { - Playlist = new List<QueueItem>(); + Reason = reason; + LastUpdate = lastUpdate; + Playlist = playlist; + PlayingItemIndex = playingItemIndex; + StartPositionTicks = startPositionTicks; + ShuffleMode = shuffleMode; + RepeatMode = repeatMode; } /// <summary> - /// Gets or sets the request type that originated this update. + /// Gets the request type that originated this update. /// </summary> /// <value>The reason for the update.</value> - public PlayQueueUpdateReason Reason { get; set; } + public PlayQueueUpdateReason Reason { get; } /// <summary> - /// Gets or sets the UTC time of the last change to the playing queue. + /// Gets the UTC time of the last change to the playing queue. /// </summary> /// <value>The UTC time of the last change to the playing queue.</value> - public DateTime LastUpdate { get; set; } + public DateTime LastUpdate { get; } /// <summary> - /// Gets or sets the playlist. + /// Gets the playlist. /// </summary> /// <value>The playlist.</value> - public IReadOnlyList<QueueItem> Playlist { get; set; } + public IReadOnlyList<QueueItem> Playlist { get; } /// <summary> - /// Gets or sets the playing item index in the playlist. + /// Gets the playing item index in the playlist. /// </summary> /// <value>The playing item index in the playlist.</value> - public int PlayingItemIndex { get; set; } + public int PlayingItemIndex { get; } /// <summary> - /// Gets or sets the start position ticks. + /// Gets the start position ticks. /// </summary> /// <value>The start position ticks.</value> - public long StartPositionTicks { get; set; } + public long StartPositionTicks { get; } /// <summary> - /// Gets or sets the shuffle mode. + /// Gets the shuffle mode. /// </summary> /// <value>The shuffle mode.</value> - public GroupShuffleMode ShuffleMode { get; set; } + public GroupShuffleMode ShuffleMode { get; } /// <summary> - /// Gets or sets the repeat mode. + /// Gets the repeat mode. /// </summary> /// <value>The repeat mode.</value> - public GroupRepeatMode RepeatMode { get; set; } + public GroupRepeatMode RepeatMode { get; } } } diff --git a/MediaBrowser.Model/SyncPlay/SendCommand.cs b/MediaBrowser.Model/SyncPlay/SendCommand.cs index a3aa54b38..ab4c64130 100644 --- a/MediaBrowser.Model/SyncPlay/SendCommand.cs +++ b/MediaBrowser.Model/SyncPlay/SendCommand.cs @@ -10,23 +10,33 @@ namespace MediaBrowser.Model.SyncPlay /// <summary> /// Initializes a new instance of the <see cref="SendCommand"/> class. /// </summary> - public SendCommand() + /// <param name="groupId">The group identifier.</param> + /// <param name="playlistItemId">The playlist identifier of the playing item.</param> + /// <param name="when">The UTC time when to execute the command.</param> + /// <param name="command">The command.</param> + /// <param name="positionTicks">The position ticks, for commands that require it.</param> + /// <param name="emittedAt">The UTC time when this command has been emitted.</param> + public SendCommand(Guid groupId, string playlistItemId, DateTime when, SendCommandType command, long? positionTicks, DateTime emittedAt) { - GroupId = string.Empty; - PlaylistItemId = string.Empty; + GroupId = groupId; + PlaylistItemId = playlistItemId; + When = when; + Command = command; + PositionTicks = positionTicks; + EmittedAt = emittedAt; } /// <summary> - /// Gets or sets the group identifier. + /// Gets the group identifier. /// </summary> /// <value>The group identifier.</value> - public string GroupId { get; set; } + public Guid GroupId { get; } /// <summary> - /// Gets or sets the playlist identifier of the playing item. + /// Gets the playlist identifier of the playing item. /// </summary> /// <value>The playlist identifier of the playing item.</value> - public string PlaylistItemId { get; set; } + public string PlaylistItemId { get; } /// <summary> /// Gets or sets the UTC time when to execute the command. @@ -35,21 +45,21 @@ namespace MediaBrowser.Model.SyncPlay public DateTime When { get; set; } /// <summary> - /// Gets or sets the position ticks. + /// Gets the position ticks. /// </summary> /// <value>The position ticks.</value> - public long? PositionTicks { get; set; } + public long? PositionTicks { get; } /// <summary> - /// Gets or sets the command. + /// Gets the command. /// </summary> /// <value>The command.</value> - public SendCommandType Command { get; set; } + public SendCommandType Command { get; } /// <summary> - /// Gets or sets the UTC time when this command has been emitted. + /// Gets the UTC time when this command has been emitted. /// </summary> /// <value>The UTC time when this command has been emitted.</value> - public DateTime EmittedAt { get; set; } + public DateTime EmittedAt { get; } } } diff --git a/MediaBrowser.Model/SyncPlay/UtcTimeResponse.cs b/MediaBrowser.Model/SyncPlay/UtcTimeResponse.cs index 8ec5eaab3..219e7b1e0 100644 --- a/MediaBrowser.Model/SyncPlay/UtcTimeResponse.cs +++ b/MediaBrowser.Model/SyncPlay/UtcTimeResponse.cs @@ -1,4 +1,4 @@ -#nullable disable +using System; namespace MediaBrowser.Model.SyncPlay { @@ -8,15 +8,26 @@ namespace MediaBrowser.Model.SyncPlay public class UtcTimeResponse { /// <summary> - /// Gets or sets the UTC time when request has been received. + /// Initializes a new instance of the <see cref="UtcTimeResponse"/> class. + /// </summary> + /// <param name="requestReceptionTime">The UTC time when request has been received.</param> + /// <param name="responseTransmissionTime">The UTC time when response has been sent.</param> + public UtcTimeResponse(DateTime requestReceptionTime, DateTime responseTransmissionTime) + { + RequestReceptionTime = requestReceptionTime; + ResponseTransmissionTime = responseTransmissionTime; + } + + /// <summary> + /// Gets the UTC time when request has been received. /// </summary> /// <value>The UTC time when request has been received.</value> - public string RequestReceptionTime { get; set; } + public DateTime RequestReceptionTime { get; } /// <summary> - /// Gets or sets the UTC time when response has been sent. + /// Gets the UTC time when response has been sent. /// </summary> /// <value>The UTC time when response has been sent.</value> - public string ResponseTransmissionTime { get; set; } + public DateTime ResponseTransmissionTime { get; } } } |
