aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/SyncPlay
diff options
context:
space:
mode:
authorgion <oancaionutandrei@gmail.com>2020-05-09 14:34:07 +0200
committergion <oancaionutandrei@gmail.com>2020-05-09 14:34:07 +0200
commit5c8cbd4087261f13d003d7d4eab082cbf335b4d4 (patch)
treeb777fc583e54ea1b4a676cab0ad05bf9df903a1f /Emby.Server.Implementations/SyncPlay
parent8a6ec2fb713cb77e91d2fceea8b4fce8e7d17395 (diff)
Fix code issues
Diffstat (limited to 'Emby.Server.Implementations/SyncPlay')
-rw-r--r--Emby.Server.Implementations/SyncPlay/SyncPlayController.cs4
-rw-r--r--Emby.Server.Implementations/SyncPlay/SyncPlayManager.cs28
2 files changed, 22 insertions, 10 deletions
diff --git a/Emby.Server.Implementations/SyncPlay/SyncPlayController.cs b/Emby.Server.Implementations/SyncPlay/SyncPlayController.cs
index 9c9758de1..c7bd242a7 100644
--- a/Emby.Server.Implementations/SyncPlay/SyncPlayController.cs
+++ b/Emby.Server.Implementations/SyncPlay/SyncPlayController.cs
@@ -144,7 +144,7 @@ namespace Emby.Server.Implementations.SyncPlay
session => session.Session
).ToArray();
default:
- return new SessionInfo[] { };
+ return Array.Empty<SessionInfo>();
}
}
@@ -541,7 +541,7 @@ namespace Emby.Server.Implementations.SyncPlay
PlayingItemName = _group.PlayingItem.Name,
PlayingItemId = _group.PlayingItem.Id.ToString(),
PositionTicks = _group.PositionTicks,
- Participants = _group.Participants.Values.Select(session => session.Session.UserName).Distinct().ToArray()
+ Participants = _group.Participants.Values.Select(session => session.Session.UserName).Distinct().ToList().AsReadOnly()
};
}
}
diff --git a/Emby.Server.Implementations/SyncPlay/SyncPlayManager.cs b/Emby.Server.Implementations/SyncPlay/SyncPlayManager.cs
index d3197d97b..93cec1304 100644
--- a/Emby.Server.Implementations/SyncPlay/SyncPlayManager.cs
+++ b/Emby.Server.Implementations/SyncPlay/SyncPlayManager.cs
@@ -47,8 +47,8 @@ namespace Emby.Server.Implementations.SyncPlay
/// <summary>
/// The groups.
/// </summary>
- private readonly Dictionary<string, ISyncPlayController> _groups =
- new Dictionary<string, ISyncPlayController>(StringComparer.OrdinalIgnoreCase);
+ private readonly Dictionary<Guid, ISyncPlayController> _groups =
+ new Dictionary<Guid, ISyncPlayController>();
/// <summary>
/// Lock used for accesing any group.
@@ -113,14 +113,22 @@ namespace Emby.Server.Implementations.SyncPlay
private void OnSessionManagerSessionEnded(object sender, SessionEventArgs e)
{
var session = e.SessionInfo;
- if (!IsSessionInGroup(session)) return;
+ if (!IsSessionInGroup(session))
+ {
+ return;
+ }
+
LeaveGroup(session, CancellationToken.None);
}
private void OnSessionManagerPlaybackStopped(object sender, PlaybackStopEventArgs e)
{
var session = e.Session;
- if (!IsSessionInGroup(session)) return;
+ if (!IsSessionInGroup(session))
+ {
+ return;
+ }
+
LeaveGroup(session, CancellationToken.None);
}
@@ -193,14 +201,14 @@ namespace Emby.Server.Implementations.SyncPlay
}
var group = new SyncPlayController(_sessionManager, this);
- _groups[group.GetGroupId().ToString()] = group;
+ _groups[group.GetGroupId()] = group;
group.InitGroup(session, cancellationToken);
}
}
/// <inheritdoc />
- public void JoinGroup(SessionInfo session, string groupId, JoinGroupRequest request, CancellationToken cancellationToken)
+ public void JoinGroup(SessionInfo session, Guid groupId, JoinGroupRequest request, CancellationToken cancellationToken)
{
var user = _userManager.GetUserById(session.UserId);
@@ -248,7 +256,11 @@ namespace Emby.Server.Implementations.SyncPlay
if (IsSessionInGroup(session))
{
- if (GetSessionGroup(session).Equals(groupId)) return;
+ if (GetSessionGroup(session).Equals(groupId))
+ {
+ return;
+ }
+
LeaveGroup(session, cancellationToken);
}
@@ -282,7 +294,7 @@ namespace Emby.Server.Implementations.SyncPlay
if (group.IsGroupEmpty())
{
_logger.LogInformation("LeaveGroup: removing empty group {0}.", group.GetGroupId());
- _groups.Remove(group.GetGroupId().ToString(), out _);
+ _groups.Remove(group.GetGroupId(), out _);
}
}
}