コード例 #1
0
        public void Execute(IEvent @event)
        {
            var connectionId = @event.ConnectionId;

            var clientProtocol = _auth.ClientProtocolVersion(connectionId);

            SendTrackInfo(clientProtocol, connectionId);
            SendTrackRating(connectionId);
            SendLfmRating(connectionId);

            var statusMessage = new SocketMessage(Constants.PlayerStatus, _apiAdapter.GetStatus());

            _hub.Publish(new PluginResponseAvailableEvent(statusMessage, connectionId));


            if (clientProtocol >= Constants.V3)
            {
                var coverPayload  = CoverPayloadGenerator.Create(_model.Cover, true);
                var lyricsPayload = new LyricsPayload(_model.Lyrics);
                var coverMessage  = new SocketMessage(Constants.NowPlayingCover, coverPayload);
                var lyricsMessage = new SocketMessage(Constants.NowPlayingLyrics, lyricsPayload);
                _hub.Publish(new PluginResponseAvailableEvent(coverMessage, connectionId));
                _hub.Publish(new PluginResponseAvailableEvent(lyricsMessage, connectionId));
            }
            else
            {
                var coverMessage  = new SocketMessage(Constants.NowPlayingCover, _model.Cover);
                var lyricsMessage = new SocketMessage(Constants.NowPlayingLyrics, _model.Lyrics);
                _hub.Publish(new PluginResponseAvailableEvent(coverMessage, connectionId));
                _hub.Publish(new PluginResponseAvailableEvent(lyricsMessage, connectionId));
            }
        }
コード例 #2
0
 public void Execute(IEvent @event)
 {
     if (_auth.ClientProtocolVersion(@event.ConnectionId) > 2)
     {
         var lyricsPayload = new LyricsPayload(_model.Lyrics);
         var message       = new SocketMessage(Constants.NowPlayingLyrics, lyricsPayload);
         _hub.Publish(new PluginResponseAvailableEvent(message, @event.ConnectionId));
     }
     else
     {
         var message = new SocketMessage(Constants.NowPlayingLyrics, _model.Lyrics);
         _hub.Publish(new PluginResponseAvailableEvent(message, @event.ConnectionId));
     }
 }
コード例 #3
0
ファイル: RequestLyrics.cs プロジェクト: kelsos/plugin
        public void Execute(IEvent receivedEvent)
        {
            if (receivedEvent == null)
            {
                throw new ArgumentNullException(nameof(receivedEvent));
            }

            if (_auth.ClientProtocolVersion(receivedEvent.ConnectionId) > 2)
            {
                var lyricsPayload = new LyricsPayload(_model.Lyrics);
                var message       = new SocketMessage(Constants.NowPlayingLyrics, lyricsPayload);
                _hub.Publish(new PluginResponseAvailableEvent(message, receivedEvent.ConnectionId));
            }
            else
            {
                var message = new SocketMessage(Constants.NowPlayingLyrics, _model.Lyrics);
                _hub.Publish(new PluginResponseAvailableEvent(message, receivedEvent.ConnectionId));
            }
        }