mirror of
https://github.com/ZetaKebab/MpcNET.git
synced 2025-01-14 22:18:43 +00:00
Mpc Disconnect implemented.
This commit is contained in:
parent
c95c09fa2c
commit
483f6740e0
@ -39,6 +39,19 @@ namespace LibMpc
|
|||||||
return _connection.IsConnected;
|
return _connection.IsConnected;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task DisconnectAsync()
|
||||||
|
{
|
||||||
|
if (_connection == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_connection.IsConnected)
|
||||||
|
{
|
||||||
|
await _connection?.DisconnectAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#region Admin Commands
|
#region Admin Commands
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Disables an MPD output.
|
/// Disables an MPD output.
|
||||||
|
@ -63,7 +63,7 @@ namespace LibMpc
|
|||||||
var firstLine = _reader.ReadLine();
|
var firstLine = _reader.ReadLine();
|
||||||
if (!firstLine.StartsWith(FIRST_LINE_PREFIX))
|
if (!firstLine.StartsWith(FIRST_LINE_PREFIX))
|
||||||
{
|
{
|
||||||
await Disconnect();
|
await DisconnectAsync();
|
||||||
throw new InvalidDataException("Response of mpd does not start with \"" + FIRST_LINE_PREFIX + "\"." );
|
throw new InvalidDataException("Response of mpd does not start with \"" + FIRST_LINE_PREFIX + "\"." );
|
||||||
}
|
}
|
||||||
_version = firstLine.Substring(FIRST_LINE_PREFIX.Length);
|
_version = firstLine.Substring(FIRST_LINE_PREFIX.Length);
|
||||||
@ -74,7 +74,7 @@ namespace LibMpc
|
|||||||
await ReadResponseAsync();
|
await ReadResponseAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Task Disconnect()
|
public Task DisconnectAsync()
|
||||||
{
|
{
|
||||||
if (_tcpClient == null)
|
if (_tcpClient == null)
|
||||||
{
|
{
|
||||||
@ -113,7 +113,7 @@ namespace LibMpc
|
|||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
try { await Disconnect(); } catch (Exception) { }
|
try { await DisconnectAsync(); } catch (Exception) { }
|
||||||
return null; // TODO: Create Null Object for MpdResponse
|
return null; // TODO: Create Null Object for MpdResponse
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -161,7 +161,7 @@ namespace LibMpc
|
|||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
try { await Disconnect(); } catch (Exception) { }
|
try { await DisconnectAsync(); } catch (Exception) { }
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user