aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Api/SessionsService.cs
diff options
context:
space:
mode:
authortikuf <admin@nyalindee.com>2014-04-02 08:55:36 +1100
committertikuf <admin@nyalindee.com>2014-04-02 08:55:36 +1100
commit8882925dab080eb236a5cc896f48ed99711d76a8 (patch)
treecbfa2811dfff4c818d34de926f68be2ef8a78948 /MediaBrowser.Api/SessionsService.cs
parent241be6dd93f6e0ec96ef88f0182b8985eb275995 (diff)
parent4afe2c3f731562efbe42147d1bcbdc0a7542cfeb (diff)
Merge branch 'master' of https://github.com/MediaBrowser/MediaBrowser
Diffstat (limited to 'MediaBrowser.Api/SessionsService.cs')
-rw-r--r--MediaBrowser.Api/SessionsService.cs74
1 files changed, 71 insertions, 3 deletions
diff --git a/MediaBrowser.Api/SessionsService.cs b/MediaBrowser.Api/SessionsService.cs
index a509c876c..1f3bcf75b 100644
--- a/MediaBrowser.Api/SessionsService.cs
+++ b/MediaBrowser.Api/SessionsService.cs
@@ -146,7 +146,36 @@ namespace MediaBrowser.Api
/// </summary>
/// <value>The play command.</value>
[ApiMember(Name = "Command", Description = "The command to send.", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "POST")]
- public SystemCommand Command { get; set; }
+ public string Command { get; set; }
+ }
+
+ [Route("/Sessions/{Id}/Command/{Command}", "POST", Summary = "Issues a system command to a client")]
+ public class SendGeneralCommand : IReturnVoid
+ {
+ /// <summary>
+ /// Gets or sets the id.
+ /// </summary>
+ /// <value>The id.</value>
+ [ApiMember(Name = "Id", Description = "Session Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "POST")]
+ public Guid Id { get; set; }
+
+ /// <summary>
+ /// Gets or sets the command.
+ /// </summary>
+ /// <value>The play command.</value>
+ [ApiMember(Name = "Command", Description = "The command to send.", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "POST")]
+ public string Command { get; set; }
+ }
+
+ [Route("/Sessions/{Id}/Command", "POST", Summary = "Issues a system command to a client")]
+ public class SendFullGeneralCommand : GeneralCommand, IReturnVoid
+ {
+ /// <summary>
+ /// Gets or sets the id.
+ /// </summary>
+ /// <value>The id.</value>
+ [ApiMember(Name = "Id", Description = "Session Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "POST")]
+ public Guid Id { get; set; }
}
[Route("/Sessions/{Id}/Message", "POST", Summary = "Issues a command to a client to display a message to the user")]
@@ -301,9 +330,22 @@ namespace MediaBrowser.Api
/// <param name="request">The request.</param>
public void Post(SendSystemCommand request)
{
- var task = _sessionManager.SendSystemCommand(GetSession().Id, request.Id, request.Command, CancellationToken.None);
+ GeneralCommandType commandType;
- Task.WaitAll(task);
+ if (Enum.TryParse(request.Command, true, out commandType))
+ {
+ var currentSession = GetSession();
+
+ var command = new GeneralCommand
+ {
+ Name = commandType.ToString(),
+ ControllingUserId = currentSession.UserId.HasValue ? currentSession.UserId.Value.ToString("N") : null
+ };
+
+ var task = _sessionManager.SendGeneralCommand(currentSession.Id, request.Id, command, CancellationToken.None);
+
+ Task.WaitAll(task);
+ }
}
/// <summary>
@@ -343,6 +385,32 @@ namespace MediaBrowser.Api
Task.WaitAll(task);
}
+ public void Post(SendGeneralCommand request)
+ {
+ var currentSession = GetSession();
+
+ var command = new GeneralCommand
+ {
+ Name = request.Command,
+ ControllingUserId = currentSession.UserId.HasValue ? currentSession.UserId.Value.ToString("N") : null
+ };
+
+ var task = _sessionManager.SendGeneralCommand(currentSession.Id, request.Id, command, CancellationToken.None);
+
+ Task.WaitAll(task);
+ }
+
+ public void Post(SendFullGeneralCommand request)
+ {
+ var currentSession = GetSession();
+
+ request.ControllingUserId = currentSession.UserId.HasValue ? currentSession.UserId.Value.ToString("N") : null;
+
+ var task = _sessionManager.SendGeneralCommand(currentSession.Id, request.Id, request, CancellationToken.None);
+
+ Task.WaitAll(task);
+ }
+
public void Post(AddUserToSession request)
{
_sessionManager.AddAdditionalUser(request.Id, request.UserId);