1
0
mirror of https://github.com/ZetaKebab/MpcNET.git synced 2025-01-14 22:18:43 +00:00

After connection is established is no need to send empty line to the server.

This commit is contained in:
glucaci 2016-12-16 11:30:14 +01:00
parent 92e9d2b225
commit 9791b8943f

View File

@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq;
using System.Net; using System.Net;
using System.Net.Sockets; using System.Net.Sockets;
using System.Text; using System.Text;
@ -59,11 +60,6 @@ namespace LibMpc
throw new InvalidDataException("Response of mpd does not start with \"" + Constants.FirstLinePrefix + "\"." ); throw new InvalidDataException("Response of mpd does not start with \"" + Constants.FirstLinePrefix + "\"." );
} }
_version = firstLine.Substring(Constants.FirstLinePrefix.Length); _version = firstLine.Substring(Constants.FirstLinePrefix.Length);
await _writer.WriteLineAsync();
_writer.Flush();
await ReadResponseAsync();
} }
public Task DisconnectAsync() public Task DisconnectAsync()
@ -123,9 +119,9 @@ namespace LibMpc
{ {
responseLine = await _reader.ReadLineAsync(); responseLine = await _reader.ReadLineAsync();
response.Add(responseLine); 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() private void ClearConnectionFields()