From 5b3bde4d9a21066b3b62f52b95a4a88b9e0d3a7e Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 16 Mar 2014 12:15:10 -0400 Subject: fixed dlna user reporting --- .../Session/SessionManager.cs | 78 ++++++++++------------ 1 file changed, 34 insertions(+), 44 deletions(-) (limited to 'MediaBrowser.Server.Implementations/Session') diff --git a/MediaBrowser.Server.Implementations/Session/SessionManager.cs b/MediaBrowser.Server.Implementations/Session/SessionManager.cs index cea70a8b4e..3acc5e892c 100644 --- a/MediaBrowser.Server.Implementations/Session/SessionManager.cs +++ b/MediaBrowser.Server.Implementations/Session/SessionManager.cs @@ -622,42 +622,27 @@ namespace MediaBrowser.Server.Implementations.Session return session; } - /// - /// Sends the system command. - /// - /// The session id. - /// The command. - /// The cancellation token. - /// Task. - 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); } - /// - /// Sends the message command. - /// - /// The session id. - /// The command. - /// The cancellation token. - /// Task. - 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); } - /// - /// Sends the play command. - /// - /// The session id. - /// The command. - /// The cancellation token. - /// Task. - 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); } - /// - /// Sends the browse command. - /// - /// The session id. - /// The command. - /// The cancellation token. - /// Task. - 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); } - /// - /// Sends the playstate command. - /// - /// The session id. - /// The command. - /// The cancellation token. - /// Task. - 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"); + } + } + /// /// Sends the restart required message. /// -- cgit v1.2.3