public Task SendBrowseCommand(string controllingSessionId, string sessionId, BrowseRequest command, CancellationToken cancellationToken) { var generalCommand = new GeneralCommand { Name = GeneralCommandType.DisplayContent.ToString() }; generalCommand.Arguments["ItemId"] = command.ItemId; generalCommand.Arguments["ItemName"] = command.ItemName; generalCommand.Arguments["ItemType"] = command.ItemType; return SendGeneralCommand(controllingSessionId, sessionId, generalCommand, cancellationToken); }
public Task SendMessageCommand(string controllingSessionId, string sessionId, MessageCommand command, CancellationToken cancellationToken) { var generalCommand = new GeneralCommand { Name = GeneralCommandType.DisplayMessage.ToString() }; generalCommand.Arguments["Header"] = command.Header; generalCommand.Arguments["Text"] = command.Text; if (command.TimeoutMs.HasValue) { generalCommand.Arguments["TimeoutMs"] = command.TimeoutMs.Value.ToString(CultureInfo.InvariantCulture); } return SendGeneralCommand(controllingSessionId, sessionId, generalCommand, cancellationToken); }
public Task SendGeneralCommand(string controllingSessionId, string sessionId, GeneralCommand command, CancellationToken cancellationToken) { var session = GetSession(sessionId); var controllingSession = GetSession(controllingSessionId); AssertCanControl(session, controllingSession); return session.SessionController.SendGeneralCommand(command, cancellationToken); }
public Task SendGeneralCommand(GeneralCommand command, CancellationToken cancellationToken) { return SendMessage(command.Name, command.Arguments, cancellationToken); }
public Task SendGeneralCommand(GeneralCommand command, CancellationToken cancellationToken) { var socket = GetActiveSocket(); return socket.SendAsync(new WebSocketMessage<GeneralCommand> { MessageType = "GeneralCommand", Data = command }, cancellationToken); }
public Task SendGeneralCommand(GeneralCommand command, CancellationToken cancellationToken) { GeneralCommandType commandType; if (Enum.TryParse(command.Name, true, out commandType)) { switch (commandType) { case GeneralCommandType.VolumeDown: return _device.VolumeDown(); case GeneralCommandType.VolumeUp: return _device.VolumeUp(); case GeneralCommandType.Mute: return _device.Mute(); case GeneralCommandType.Unmute: return _device.Unmute(); case GeneralCommandType.ToggleMute: return _device.ToggleMute(); case GeneralCommandType.SetAudioStreamIndex: { string arg; if (command.Arguments.TryGetValue("Index", out arg)) { int val; if (Int32.TryParse(arg, NumberStyles.Any, _usCulture, out val)) { return SetAudioStreamIndex(val); } throw new ArgumentException("Unsupported SetAudioStreamIndex value supplied."); } throw new ArgumentException("SetAudioStreamIndex argument cannot be null"); } case GeneralCommandType.SetSubtitleStreamIndex: { string arg; if (command.Arguments.TryGetValue("Index", out arg)) { int val; if (Int32.TryParse(arg, NumberStyles.Any, _usCulture, out val)) { return SetSubtitleStreamIndex(val); } throw new ArgumentException("Unsupported SetSubtitleStreamIndex value supplied."); } throw new ArgumentException("SetSubtitleStreamIndex argument cannot be null"); } case GeneralCommandType.SetVolume: { string arg; if (command.Arguments.TryGetValue("Volume", out arg)) { int volume; if (Int32.TryParse(arg, NumberStyles.Any, _usCulture, out volume)) { return _device.SetVolume(volume); } throw new ArgumentException("Unsupported volume value supplied."); } throw new ArgumentException("Volume argument cannot be null"); } default: return Task.FromResult(true); } } return Task.FromResult(true); }
public Task SendGeneralCommand(GeneralCommand command, CancellationToken cancellationToken) { return SendCommand(new WebSocketMessage<GeneralCommand> { MessageType = "Command", Data = command }, cancellationToken); }
public Task SendGeneralCommand(GeneralCommand command, CancellationToken cancellationToken) { GeneralCommandType commandType; if (!Enum.TryParse(command.Name, true, out commandType)) { switch (commandType) { case GeneralCommandType.VolumeDown: return _device.VolumeDown(); case GeneralCommandType.VolumeUp: return _device.VolumeUp(); case GeneralCommandType.Mute: return _device.VolumeDown(true); case GeneralCommandType.Unmute: return _device.VolumeUp(true); case GeneralCommandType.ToggleMute: return _device.ToggleMute(); default: return Task.FromResult(true); } } return Task.FromResult(true); }