예제 #1
0
        public virtual int HandleResponse(IMpdResponse response)
        {
            if (response.IsErrorResponse)
            {
                return(0);
            }

            return(Convert.ToInt32(response.GetContent().First() ?? string.Empty));
        }
예제 #2
0
        public virtual IJob HandleResponse(IMpdResponse response)
        {
            if (response.IsErrorResponse)
            {
                return(null);
            }

            var parser = new ResponseParser(response);

            return(parser.GetJobInformation());
        }
예제 #3
0
        public IEnumerable <IPlaylist> HandleResponse(IMpdResponse response)
        {
            if (response.HasContent)
            {
                return(null);
            }

            var parser = new ResponseParser(response);

            return(parser.GetListedPlaylists());
        }
예제 #4
0
        public int HandleResponse(IMpdResponse response)
        {
            if (response.IsErrorResponse)
            {
                return(0);
            }

            var parser = new ResponseParser(response);

            return(parser.GetItemId());
        }
예제 #5
0
        /// <summary>
        /// Handles the response and returns an item DTO or null if none is found
        /// </summary>
        /// <param name="response">MPD response</param>
        /// <returns>item DTO with metadata</returns>
        public IItem HandleResponse(IMpdResponse response)
        {
            if (!response.HasContent)
            {
                return(null);
            }

            var parser = new ResponseParser(response);

            return(parser.GetListedTracks().ToList().FirstOrDefault());
        }
예제 #6
0
        public virtual IDirectory HandleResponse(IMpdResponse response)
        {
            if (response.IsErrorResponse)
            {
                return(null);
            }

            var parser = new ResponseParser(response);

            return(parser.GetDirectoryListing(Path));
        }
예제 #7
0
        public virtual IEnumerable <string> HandleResponse(IMpdResponse response)
        {
            if (response.IsErrorResponse)
            {
                return(null);
            }

            var parser = new ResponseParser(response);

            return(parser.GetValueList(Key));
        }
예제 #8
0
        public ISticker HandleResponse(IMpdResponse response)
        {
            if (response.IsErrorResponse)
            {
                return(null);
            }

            var parser = new ResponseParser(response);

            return(parser.GetListedSticker(Path, StickerType).FirstOrDefault());
        }
예제 #9
0
        public virtual IEnumerable <ISticker> HandleResponse(IMpdResponse response)
        {
            if (response.IsErrorResponse)
            {
                return(null);
            }

            var parser = new ResponseParser(response);

            return(parser.GetListedSticker(Path, StickerType));
        }
예제 #10
0
        public virtual IQueue HandleResponse(IMpdResponse response)
        {
            if (!response.HasContent)
            {
                return(null);
            }

            var parser = new ResponseParser(response);

            return(new Mpd.Queue
            {
                Items = parser.GetListedTracks()
            });
        }
예제 #11
0
        public virtual IPlaylist HandleResponse(IMpdResponse response)
        {
            if (response.IsErrorResponse)
            {
                return(null);
            }

            var parser = new ResponseParser(response);

            return(new Mpd.Playlist
            {
                Name = PlaylistName,
                LastModified = parser.GetLastModified(),
                Items = parser.GetListedTracks()
            });
        }
예제 #12
0
        public async Task <IMpcCoreResponse <T> > SendAsync <T>(IMpcCoreCommand <T> command)
        {
            if (command == null)
            {
                return(new MpcCoreResponse <T>(command, new MpcCoreResponseStatus
                {
                    HasError = true,
                    ErrorMessage = "Command is null or empty"
                }));
            }

            IMpdResponse response = null;

            try {
                response = await _connection.SendAsync(command);
            }
            catch (Exception exception)
            {
                try
                {
                    await _connection.DisconnectAsync();
                }
                catch (Exception)
                {
                    // TODO handle exception correctly
                }

                return(new MpcCoreResponse <T>(command, new MpcCoreResponseStatus
                {
                    HasError = true,
                    ErrorMessage = $"An exception occured: {exception.Message} in {exception.Source}"
                }));
            }

            return(await new MpcCoreResponse <T>(command, response).CreateResult());
        }
예제 #13
0
        public string HandleResponse(IMpdResponse response)
        {
            var parser = new ResponseParser(response);

            return(parser.GetReplayGainStatus());
        }
예제 #14
0
        public IEnumerable <IDecoderPlugin> HandleResponse(IMpdResponse response)
        {
            var parser = new ResponseParser(response);

            return(parser.GetListedDecoderPlugins());
        }
예제 #15
0
        public IStatistics HandleResponse(IMpdResponse response)
        {
            var parser = new ResponseParser(response);

            return(parser.GetStatistics());
        }
예제 #16
0
        public IEnumerable <IItem> HandleResponse(IMpdResponse response)
        {
            var parser = new ResponseParser(response);

            return(parser.GetListedTracks());
        }
예제 #17
0
 public virtual bool HandleResponse(IMpdResponse response)
 {
     return(response.IsOkResponse);
 }
예제 #18
0
        public IEnumerable <string> HandleResponse(IMpdResponse response)
        {
            var parser = new ResponseParser(response);

            return(parser.GetChangedSystems());
        }
예제 #19
0
 public MpcCoreResponse(IMpcCoreCommand <T> command, IMpdResponse response)
 {
     _response = response;
     Command   = command;
 }
예제 #20
0
        public string HandleResponse(IMpdResponse response)
        {
            var parser = new ResponseParser(response);

            return(parser.GetFingerprint());
        }
예제 #21
0
 /// <summary>
 /// Constructor.
 /// Takes the response from the server and calls <see cref="_getKeyValuePairs"/> to create the valueList for further processing
 /// </summary>
 /// <param name="response">Response string list from the MPD server</param>
 public ResponseParser(IMpdResponse response)
 {
     _response  = response;
     _valueList = _getKeyValuePairs(response.RawResponse);
 }
예제 #22
0
 public virtual IBinaryChunk HandleResponse(IMpdResponse response)
 {
     return(response.BinaryChunk);
 }
예제 #23
0
        public IEnumerable <INeighbor> HandleResponse(IMpdResponse response)
        {
            var parser = new ResponseParser(response);

            return(parser.GetListedNeighbors());
        }
예제 #24
0
        public IEnumerable <KeyValuePair <string, string> > HandleResponse(IMpdResponse response)
        {
            var parser = new ResponseParser(response);

            return(parser.GetKeyValueList());
        }
예제 #25
0
        public IEnumerable <IMount> HandleResponse(IMpdResponse response)
        {
            var parser = new ResponseParser(response);

            return(parser.GetListedMounts());
        }
예제 #26
0
        public int?HandleResponse(IMpdResponse response)
        {
            var parser = new ResponseParser(response);

            return(parser.GetVolume());
        }
예제 #27
0
        public IEnumerable <IOutputDevice> HandleResponse(IMpdResponse response)
        {
            var parser = new ResponseParser(response);

            return(parser.GetListedOutputDevices());
        }