diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2013-09-24 11:42:30 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2013-09-24 11:42:30 -0400 |
| commit | c61cc4a304978a59f66c86c3618f8f6dd8ccca7b (patch) | |
| tree | b42db241185bac265c315998a880a24d24b56b04 /MediaBrowser.Api/SessionsService.cs | |
| parent | 04319900f9ac6ebac0668927ddb38212f37477d0 (diff) | |
support more kinds of remote control besides web socket
Diffstat (limited to 'MediaBrowser.Api/SessionsService.cs')
| -rw-r--r-- | MediaBrowser.Api/SessionsService.cs | 40 |
1 files changed, 1 insertions, 39 deletions
diff --git a/MediaBrowser.Api/SessionsService.cs b/MediaBrowser.Api/SessionsService.cs index cad3c4384..b93b5326e 100644 --- a/MediaBrowser.Api/SessionsService.cs +++ b/MediaBrowser.Api/SessionsService.cs @@ -325,49 +325,11 @@ namespace MediaBrowser.Api /// <param name="request">The request.</param> public void Post(SendSystemCommand request) { - var task = SendSystemCommand(request); + var task = _sessionManager.SendSystemCommand(request.Id, request.Command, CancellationToken.None); Task.WaitAll(task); } - private async Task SendSystemCommand(SendSystemCommand request) - { - var session = _sessionManager.Sessions.FirstOrDefault(i => i.Id == request.Id); - - if (session == null) - { - throw new ResourceNotFoundException(string.Format("Session {0} not found.", request.Id)); - } - - if (!session.SupportsRemoteControl) - { - throw new ArgumentException(string.Format("Session {0} does not support remote control.", session.Id)); - } - - var socket = session.WebSockets.OrderByDescending(i => i.LastActivityDate).FirstOrDefault(i => i.State == WebSocketState.Open); - - if (socket != null) - { - try - { - await socket.SendAsync(new WebSocketMessage<string> - { - MessageType = "SystemCommand", - Data = request.Command.ToString() - - }, CancellationToken.None).ConfigureAwait(false); - } - catch (Exception ex) - { - Logger.ErrorException("Error sending web socket message", ex); - } - } - else - { - throw new InvalidOperationException("The requested session does not have an open web socket."); - } - } - /// <summary> /// Posts the specified request. /// </summary> |
