fixed dlna user reporting
This commit is contained in:
parent
b36aea4ff7
commit
5b3bde4d9a
|
@ -277,7 +277,7 @@ namespace MediaBrowser.Api
|
|||
SeekPositionTicks = request.SeekPositionTicks
|
||||
};
|
||||
|
||||
var task = _sessionManager.SendPlaystateCommand(request.Id, command, CancellationToken.None);
|
||||
var task = _sessionManager.SendPlaystateCommand(GetSession().Id, request.Id, command, CancellationToken.None);
|
||||
|
||||
Task.WaitAll(task);
|
||||
}
|
||||
|
@ -296,7 +296,7 @@ namespace MediaBrowser.Api
|
|||
ItemType = request.ItemType
|
||||
};
|
||||
|
||||
var task = _sessionManager.SendBrowseCommand(request.Id, command, CancellationToken.None);
|
||||
var task = _sessionManager.SendBrowseCommand(GetSession().Id, request.Id, command, CancellationToken.None);
|
||||
|
||||
Task.WaitAll(task);
|
||||
}
|
||||
|
@ -307,7 +307,7 @@ namespace MediaBrowser.Api
|
|||
/// <param name="request">The request.</param>
|
||||
public void Post(SendSystemCommand request)
|
||||
{
|
||||
var task = _sessionManager.SendSystemCommand(request.Id, request.Command, CancellationToken.None);
|
||||
var task = _sessionManager.SendSystemCommand(GetSession().Id, request.Id, request.Command, CancellationToken.None);
|
||||
|
||||
Task.WaitAll(task);
|
||||
}
|
||||
|
@ -325,7 +325,7 @@ namespace MediaBrowser.Api
|
|||
Text = request.Text
|
||||
};
|
||||
|
||||
var task = _sessionManager.SendMessageCommand(request.Id, command, CancellationToken.None);
|
||||
var task = _sessionManager.SendMessageCommand(GetSession().Id, request.Id, command, CancellationToken.None);
|
||||
|
||||
Task.WaitAll(task);
|
||||
}
|
||||
|
@ -344,7 +344,7 @@ namespace MediaBrowser.Api
|
|||
StartPositionTicks = request.StartPositionTicks
|
||||
};
|
||||
|
||||
var task = _sessionManager.SendPlayCommand(request.Id, command, CancellationToken.None);
|
||||
var task = _sessionManager.SendPlayCommand(GetSession().Id, request.Id, command, CancellationToken.None);
|
||||
|
||||
Task.WaitAll(task);
|
||||
}
|
||||
|
@ -367,5 +367,14 @@ namespace MediaBrowser.Api
|
|||
.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
private SessionInfo GetSession()
|
||||
{
|
||||
var auth = AuthorizationRequestFilterAttribute.GetAuthorization(Request);
|
||||
|
||||
return _sessionManager.Sessions.First(i => string.Equals(i.DeviceId, auth.DeviceId) &&
|
||||
string.Equals(i.Client, auth.Client) &&
|
||||
string.Equals(i.ApplicationVersion, auth.Version));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -86,47 +86,52 @@ namespace MediaBrowser.Controller.Session
|
|||
/// <summary>
|
||||
/// Sends the system command.
|
||||
/// </summary>
|
||||
/// <param name="controllingSessionId">The controlling session identifier.</param>
|
||||
/// <param name="sessionId">The session id.</param>
|
||||
/// <param name="command">The command.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task.</returns>
|
||||
Task SendSystemCommand(Guid sessionId, SystemCommand command, CancellationToken cancellationToken);
|
||||
Task SendSystemCommand(Guid controllingSessionId, Guid sessionId, SystemCommand command, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Sends the message command.
|
||||
/// </summary>
|
||||
/// <param name="controllingSessionId">The controlling session identifier.</param>
|
||||
/// <param name="sessionId">The session id.</param>
|
||||
/// <param name="command">The command.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task.</returns>
|
||||
Task SendMessageCommand(Guid sessionId, MessageCommand command, CancellationToken cancellationToken);
|
||||
Task SendMessageCommand(Guid controllingSessionId, Guid sessionId, MessageCommand command, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Sends the play command.
|
||||
/// </summary>
|
||||
/// <param name="controllingSessionId">The controlling session identifier.</param>
|
||||
/// <param name="sessionId">The session id.</param>
|
||||
/// <param name="command">The command.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task.</returns>
|
||||
Task SendPlayCommand(Guid sessionId, PlayRequest command, CancellationToken cancellationToken);
|
||||
Task SendPlayCommand(Guid controllingSessionId, Guid sessionId, PlayRequest command, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Sends the browse command.
|
||||
/// </summary>
|
||||
/// <param name="controllingSessionId">The controlling session identifier.</param>
|
||||
/// <param name="sessionId">The session id.</param>
|
||||
/// <param name="command">The command.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task.</returns>
|
||||
Task SendBrowseCommand(Guid sessionId, BrowseRequest command, CancellationToken cancellationToken);
|
||||
Task SendBrowseCommand(Guid controllingSessionId, Guid sessionId, BrowseRequest command, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Sends the playstate command.
|
||||
/// </summary>
|
||||
/// <param name="controllingSessionId">The controlling session identifier.</param>
|
||||
/// <param name="sessionId">The session id.</param>
|
||||
/// <param name="command">The command.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task.</returns>
|
||||
Task SendPlaystateCommand(Guid sessionId, PlaystateRequest command, CancellationToken cancellationToken);
|
||||
Task SendPlaystateCommand(Guid controllingSessionId, Guid sessionId, PlaystateRequest command, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Sends the restart required message.
|
||||
|
|
|
@ -56,11 +56,16 @@ namespace MediaBrowser.Providers.Manager
|
|||
/// <summary>
|
||||
/// Gets the last result.
|
||||
/// </summary>
|
||||
/// <param name="itemId">The item identifier.</param>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <returns>ProviderResult.</returns>
|
||||
protected MetadataStatus GetLastResult(Guid itemId)
|
||||
protected MetadataStatus GetLastResult(IHasMetadata item)
|
||||
{
|
||||
return ProviderRepo.GetMetadataStatus(itemId) ?? new MetadataStatus { ItemId = itemId };
|
||||
if (item.DateLastSaved == default(DateTime))
|
||||
{
|
||||
return new MetadataStatus { ItemId = item.Id };
|
||||
}
|
||||
|
||||
return ProviderRepo.GetMetadataStatus(item.Id) ?? new MetadataStatus { ItemId = item.Id };
|
||||
}
|
||||
|
||||
public async Task RefreshMetadata(IHasMetadata item, MetadataRefreshOptions refreshOptions, CancellationToken cancellationToken)
|
||||
|
@ -74,7 +79,7 @@ namespace MediaBrowser.Providers.Manager
|
|||
var config = ProviderManager.GetMetadataOptions(item);
|
||||
|
||||
var updateType = ItemUpdateType.None;
|
||||
var refreshResult = GetLastResult(item.Id);
|
||||
var refreshResult = GetLastResult(item);
|
||||
refreshResult.LastErrorMessage = string.Empty;
|
||||
refreshResult.LastStatus = ProviderRefreshStatus.Success;
|
||||
|
||||
|
|
|
@ -622,42 +622,27 @@ namespace MediaBrowser.Server.Implementations.Session
|
|||
return session;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends the system command.
|
||||
/// </summary>
|
||||
/// <param name="sessionId">The session id.</param>
|
||||
/// <param name="command">The command.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task.</returns>
|
||||
public Task SendSystemCommand(Guid sessionId, SystemCommand command, CancellationToken cancellationToken)
|
||||
public Task SendSystemCommand(Guid controllingSessionId, Guid sessionId, SystemCommand command, CancellationToken cancellationToken)
|
||||
{
|
||||
var session = GetSessionForRemoteControl(sessionId);
|
||||
|
||||
var controllingSession = GetSession(controllingSessionId);
|
||||
AssertCanControl(session, controllingSession);
|
||||
|
||||
return session.SessionController.SendSystemCommand(command, cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends the message command.
|
||||
/// </summary>
|
||||
/// <param name="sessionId">The session id.</param>
|
||||
/// <param name="command">The command.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task.</returns>
|
||||
public Task SendMessageCommand(Guid sessionId, MessageCommand command, CancellationToken cancellationToken)
|
||||
public Task SendMessageCommand(Guid controllingSessionId, Guid sessionId, MessageCommand command, CancellationToken cancellationToken)
|
||||
{
|
||||
var session = GetSessionForRemoteControl(sessionId);
|
||||
|
||||
var controllingSession = GetSession(controllingSessionId);
|
||||
AssertCanControl(session, controllingSession);
|
||||
|
||||
return session.SessionController.SendMessageCommand(command, cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends the play command.
|
||||
/// </summary>
|
||||
/// <param name="sessionId">The session id.</param>
|
||||
/// <param name="command">The command.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task.</returns>
|
||||
public Task SendPlayCommand(Guid sessionId, PlayRequest command, CancellationToken cancellationToken)
|
||||
public Task SendPlayCommand(Guid controllingSessionId, Guid sessionId, PlayRequest command, CancellationToken cancellationToken)
|
||||
{
|
||||
var session = GetSessionForRemoteControl(sessionId);
|
||||
|
||||
|
@ -690,36 +675,27 @@ namespace MediaBrowser.Server.Implementations.Session
|
|||
}
|
||||
}
|
||||
|
||||
if (session.UserId.HasValue)
|
||||
var controllingSession = GetSession(controllingSessionId);
|
||||
AssertCanControl(session, controllingSession);
|
||||
if (controllingSession.UserId.HasValue)
|
||||
{
|
||||
command.ControllingUserId = session.UserId.Value.ToString("N");
|
||||
command.ControllingUserId = controllingSession.UserId.Value.ToString("N");
|
||||
}
|
||||
|
||||
return session.SessionController.SendPlayCommand(command, cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends the browse command.
|
||||
/// </summary>
|
||||
/// <param name="sessionId">The session id.</param>
|
||||
/// <param name="command">The command.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task.</returns>
|
||||
public Task SendBrowseCommand(Guid sessionId, BrowseRequest command, CancellationToken cancellationToken)
|
||||
public Task SendBrowseCommand(Guid controllingSessionId, Guid sessionId, BrowseRequest command, CancellationToken cancellationToken)
|
||||
{
|
||||
var session = GetSessionForRemoteControl(sessionId);
|
||||
|
||||
var controllingSession = GetSession(controllingSessionId);
|
||||
AssertCanControl(session, controllingSession);
|
||||
|
||||
return session.SessionController.SendBrowseCommand(command, cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends the playstate command.
|
||||
/// </summary>
|
||||
/// <param name="sessionId">The session id.</param>
|
||||
/// <param name="command">The command.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task.</returns>
|
||||
public Task SendPlaystateCommand(Guid sessionId, PlaystateRequest command, CancellationToken cancellationToken)
|
||||
public Task SendPlaystateCommand(Guid controllingSessionId, Guid sessionId, PlaystateRequest command, CancellationToken cancellationToken)
|
||||
{
|
||||
var session = GetSessionForRemoteControl(sessionId);
|
||||
|
||||
|
@ -728,14 +704,28 @@ namespace MediaBrowser.Server.Implementations.Session
|
|||
throw new ArgumentException(string.Format("Session {0} is unable to seek.", session.Id));
|
||||
}
|
||||
|
||||
if (session.UserId.HasValue)
|
||||
var controllingSession = GetSession(controllingSessionId);
|
||||
AssertCanControl(session, controllingSession);
|
||||
if (controllingSession.UserId.HasValue)
|
||||
{
|
||||
command.ControllingUserId = session.UserId.Value.ToString("N");
|
||||
command.ControllingUserId = controllingSession.UserId.Value.ToString("N");
|
||||
}
|
||||
|
||||
return session.SessionController.SendPlaystateCommand(command, cancellationToken);
|
||||
}
|
||||
|
||||
private void AssertCanControl(SessionInfo session, SessionInfo controllingSession)
|
||||
{
|
||||
if (session == null)
|
||||
{
|
||||
throw new ArgumentNullException("session");
|
||||
}
|
||||
if (controllingSession == null)
|
||||
{
|
||||
throw new ArgumentNullException("controllingSession");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends the restart required message.
|
||||
/// </summary>
|
||||
|
|
Loading…
Reference in New Issue
Block a user