public override void Execute(IEvent @event) { var isToggle = false; var token = @event.Data as JToken; if (token != null && ((string)token).Equals("toggle")) { isToggle = true; } SocketMessage message; if (_auth.ClientProtocolMisMatch(@event.ConnectionId)) { if (isToggle) { _apiAdapter.ToggleShuffleLegacy(); } message = new SocketMessage(Constants.PlayerShuffle, _apiAdapter.GetShuffleLegacy()); } else { var shuffleState = isToggle ? _apiAdapter.SwitchShuffle() : _apiAdapter.GetShuffleState(); message = new SocketMessage(Constants.PlayerShuffle, shuffleState); } _hub.Publish(new PluginResponseAvailableEvent(message)); }
public override void Execute(IEvent receivedEvent) { if (receivedEvent == null) { throw new ArgumentNullException(nameof(receivedEvent)); } var isToggle = receivedEvent.Data is JToken token && ((string)token).Equals("toggle", StringComparison.InvariantCultureIgnoreCase); SocketMessage message; if (_auth.ClientProtocolMisMatch(receivedEvent.ConnectionId)) { if (isToggle) { _apiAdapter.ToggleShuffleLegacy(); } message = new SocketMessage(Constants.PlayerShuffle, _apiAdapter.GetShuffleLegacy()); } else { var shuffleState = isToggle ? _apiAdapter.SwitchShuffle() : _apiAdapter.GetShuffleState(); message = new SocketMessage(Constants.PlayerShuffle, shuffleState); } _hub.Publish(new PluginResponseAvailableEvent(message)); }
private void HandleTimerElapsed(object sender, ElapsedEventArgs args) { if (_apiAdapter.GetShuffleState() != _stateModel.Shuffle) { _stateModel.Shuffle = _apiAdapter.GetShuffleState(); var message = new SocketMessage(Constants.PlayerShuffle, _stateModel.Shuffle); _hub.Publish(new PluginResponseAvailableEvent(message)); } if (_apiAdapter.ScrobblingEnabled() != _stateModel.Scrobble) { _stateModel.Scrobble = _apiAdapter.ScrobblingEnabled(); var message = new SocketMessage(Constants.PlayerScrobble, _stateModel.Scrobble); _hub.Publish(new PluginResponseAvailableEvent(message)); } if (_apiAdapter.GetRepeatMode() != _stateModel.RepeatMode) { _stateModel.RepeatMode = _apiAdapter.GetRepeatMode(); var message = new SocketMessage(Constants.PlayerRepeat, _stateModel.RepeatMode); _hub.Publish(new PluginResponseAvailableEvent(message)); } }