public void Execute(IEvent @event)
        {
            var connectionId = @event.ConnectionId;

            var protocolVersion = _auth.ClientProtocolVersion(connectionId);
            var message         = protocolVersion > 2
                ? new SocketMessage(Constants.NowPlayingTrack, _apiAdapter.GetPlayingTrackInfo())
                : new SocketMessage(Constants.NowPlayingTrack, _apiAdapter.GetPlayingTrackInfoLegacy());

            _hub.Publish(new PluginResponseAvailableEvent(message, connectionId));
        }
Пример #2
0
        private void BroadcastTrackInfo()
        {
            BroadcastLfmStatus();
            BroadcastTrackRating();
            BroadcastPosition();

            var broadcastEvent = new BroadcastEvent(Constants.NowPlayingTrack);

            broadcastEvent.AddPayload(Constants.V2, _apiAdapter.GetPlayingTrackInfoLegacy());
            broadcastEvent.AddPayload(Constants.V3, _apiAdapter.GetPlayingTrackInfo());

            _hub.Publish(new BroadcastEventAvailable(broadcastEvent));
            _hub.Publish(new CoverAvailable(_apiAdapter.GetCover()));
            _hub.Publish(new LyricsAvailable(_apiAdapter.GetLyrics()));
        }
Пример #3
0
        public void Execute(IEvent receivedEvent)
        {
            if (receivedEvent == null)
            {
                throw new ArgumentNullException(nameof(receivedEvent));
            }

            var connectionId = receivedEvent.ConnectionId;

            var protocolVersion = _auth.ClientProtocolVersion(connectionId);
            var message         = protocolVersion > 2
                ? new SocketMessage(Constants.NowPlayingTrack, _apiAdapter.GetPlayingTrackInfo())
                : new SocketMessage(Constants.NowPlayingTrack, _apiAdapter.GetPlayingTrackInfoLegacy());

            _hub.Publish(new PluginResponseAvailableEvent(message, connectionId));
        }
Пример #4
0
        private void SendTrackInfo(int clientProtocol, string connectionId)
        {
            NowPlayingTrackBase trackInfo;

            if (clientProtocol >= Constants.V3)
            {
                trackInfo = _trackApiAdapter.GetPlayingTrackInfo();
            }
            else
            {
                trackInfo = _trackApiAdapter.GetPlayingTrackInfoLegacy();
            }

            var trackInfoMessage = new SocketMessage(Constants.NowPlayingTrack, trackInfo);

            _hub.Publish(new PluginResponseAvailableEvent(trackInfoMessage, connectionId));
        }