@ -162,26 +162,26 @@ namespace Emby.Server.Implementations.SyncPlay
/// <summary>
/// <summary>
/// Filters sessions of this group.
/// Filters sessions of this group.
/// </summary>
/// </summary>
/// <param name="from ">The current session.</param>
/// <param name="from Id ">The current session identifier .</param>
/// <param name="type">The filtering type.</param>
/// <param name="type">The filtering type.</param>
/// <returns>The list of sessions matching the filter.</returns>
/// <returns>The list of sessions matching the filter.</returns>
private IEnumerable < SessionInfo > FilterSessions ( SessionInfo from , SyncPlayBroadcastType type )
private IEnumerable < string > FilterSessions ( string fromId , SyncPlayBroadcastType type )
{
{
return type switch
return type switch
{
{
SyncPlayBroadcastType . CurrentSession = > new SessionInfo [ ] { from } ,
SyncPlayBroadcastType . CurrentSession = > new string [ ] { fromId } ,
SyncPlayBroadcastType . AllGroup = > _participants
SyncPlayBroadcastType . AllGroup = > _participants
. Values
. Values
. Select ( session = > session . Session ) ,
. Select ( member = > member . SessionId ) ,
SyncPlayBroadcastType . AllExceptCurrentSession = > _participants
SyncPlayBroadcastType . AllExceptCurrentSession = > _participants
. Values
. Values
. Select ( session = > session . Session )
. Select ( member = > member . SessionId )
. Where ( session = > ! session . Id . Equals ( from . Id, StringComparison . OrdinalIgnoreCase ) ) ,
. Where ( session Id = > ! sessionId . Equals ( from Id, StringComparison . OrdinalIgnoreCase ) ) ,
SyncPlayBroadcastType . AllReady = > _participants
SyncPlayBroadcastType . AllReady = > _participants
. Values
. Values
. Where ( session = > ! session . IsBuffering )
. Where ( member = > ! member . IsBuffering )
. Select ( session = > session . Session ) ,
. Select ( member = > member . SessionId ) ,
_ = > Enumerable . Empty < SessionInfo > ( )
_ = > Enumerable . Empty < string > ( )
} ;
} ;
}
}
@ -223,7 +223,7 @@ namespace Emby.Server.Implementations.SyncPlay
// Get list of users.
// Get list of users.
var users = _participants
var users = _participants
. Values
. Values
. Select ( participant = > _userManager . GetUserById ( participant . Session. UserId) ) ;
. Select ( participant = > _userManager . GetUserById ( participant . UserId) ) ;
// Find problematic users.
// Find problematic users.
var usersWithNoAccess = users . Where ( user = > ! HasAccessToQueue ( user , queue ) ) ;
var usersWithNoAccess = users . Where ( user = > ! HasAccessToQueue ( user , queue ) ) ;
@ -351,7 +351,7 @@ namespace Emby.Server.Implementations.SyncPlay
/// <returns>The group info for the clients.</returns>
/// <returns>The group info for the clients.</returns>
public GroupInfoDto GetInfo ( )
public GroupInfoDto GetInfo ( )
{
{
var participants = _participants . Values . Select ( session = > session . Session. UserName) . Distinct ( ) . ToList ( ) ;
var participants = _participants . Values . Select ( session = > session . UserName) . Distinct ( ) . ToList ( ) ;
return new GroupInfoDto ( GroupId , GroupName , _state . Type , participants , DateTime . UtcNow ) ;
return new GroupInfoDto ( GroupId , GroupName , _state . Type , participants , DateTime . UtcNow ) ;
}
}
@ -387,9 +387,9 @@ namespace Emby.Server.Implementations.SyncPlay
{
{
IEnumerable < Task > GetTasks ( )
IEnumerable < Task > GetTasks ( )
{
{
foreach ( var session in FilterSessions ( from , type ) )
foreach ( var session Id in FilterSessions ( from . Id , type ) )
{
{
yield return _sessionManager . SendSyncPlayGroupUpdate ( session , message , cancellationToken ) ;
yield return _sessionManager . SendSyncPlayGroupUpdate ( session Id , message , cancellationToken ) ;
}
}
}
}
@ -401,9 +401,9 @@ namespace Emby.Server.Implementations.SyncPlay
{
{
IEnumerable < Task > GetTasks ( )
IEnumerable < Task > GetTasks ( )
{
{
foreach ( var session in FilterSessions ( from , type ) )
foreach ( var session Id in FilterSessions ( from . Id , type ) )
{
{
yield return _sessionManager . SendSyncPlayCommand ( session , message , cancellationToken ) ;
yield return _sessionManager . SendSyncPlayCommand ( session Id , message , cancellationToken ) ;
}
}
}
}