Example #1
0
        public void Execute(IEvent @event)
        {
            var token = @event.Data as JToken;

            if (token != null && ((string)token).Equals("toggle"))
            {
                _apiAdapter.ToggleScrobbling();
            }
            var message = new SocketMessage(Constants.PlayerScrobble, _apiAdapter.ScrobblingEnabled());

            _hub.Publish(new PluginResponseAvailableEvent(message));
        }
Example #2
0
        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));
            }
        }
Example #3
0
        public void Execute(IEvent receivedEvent)
        {
            if (receivedEvent == null)
            {
                throw new ArgumentNullException(nameof(receivedEvent));
            }

            if (receivedEvent.Data is JToken token &&
                ((string)token).Equals("toggle", StringComparison.InvariantCultureIgnoreCase))
            {
                _apiAdapter.ToggleScrobbling();
            }

            var message = new SocketMessage(Constants.PlayerScrobble, _apiAdapter.ScrobblingEnabled());

            _hub.Publish(new PluginResponseAvailableEvent(message));
        }