Libmpc.MpcConnection.readResponse C# (CSharp) Method

readResponse() private method

private readResponse ( ) : MpdResponse
return MpdResponse
        private MpdResponse readResponse()
        {
            List<string> ret = new List<string>();
              string line = m_SocketManager.ReadLine();
              while (line != null && !(line.Equals(OK) || line.StartsWith(ACK))) {
            ret.Add(line);
            line = m_SocketManager.ReadLine();
              }
              if (line == null)
            line = string.Empty;

              if (line.Equals(OK))
            return new MpdResponse(new ReadOnlyCollection<string>(ret));
              else {
            Match match = ACK_REGEX.Match(line);

            if (match.Groups.Count != 5)
              throw new InvalidDataException("Error response not as expected");

            return new MpdResponse(
            int.Parse(match.Result("${code}")),
            int.Parse(match.Result("${nr}")),
            match.Result("${command}"),
            match.Result("${message}"),
            new ReadOnlyCollection<string>(ret)
            );
              }
        }