Exemple #1
0
        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));
        }
Exemple #2
0
        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));
        }