From 9791b8943f2cf56fc99a6c9e3ee95011d5760a87 Mon Sep 17 00:00:00 2001 From: glucaci Date: Fri, 16 Dec 2016 11:30:14 +0100 Subject: [PATCH] After connection is established is no need to send empty line to the server. --- LibMpc/MpcConnection.cs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/LibMpc/MpcConnection.cs b/LibMpc/MpcConnection.cs index 5eb067f..aaf6f0f 100644 --- a/LibMpc/MpcConnection.cs +++ b/LibMpc/MpcConnection.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.IO; +using System.Linq; using System.Net; using System.Net.Sockets; using System.Text; @@ -59,11 +60,6 @@ namespace LibMpc throw new InvalidDataException("Response of mpd does not start with \"" + Constants.FirstLinePrefix + "\"." ); } _version = firstLine.Substring(Constants.FirstLinePrefix.Length); - - await _writer.WriteLineAsync(); - _writer.Flush(); - - await ReadResponseAsync(); } public Task DisconnectAsync() @@ -123,9 +119,9 @@ namespace LibMpc { responseLine = await _reader.ReadLineAsync(); response.Add(responseLine); - } while (!(responseLine.Equals(Constants.Ok) || responseLine.StartsWith(Constants.Ack) || string.IsNullOrEmpty(responseLine))); + } while (!(responseLine.Equals(Constants.Ok) || responseLine.StartsWith(Constants.Ack))); - return response.ToArray(); + return response.Where(line => !string.IsNullOrEmpty(line)).ToArray(); } private void ClearConnectionFields()