mirror of
https://github.com/ZetaKebab/MpcNET.git
synced 2025-01-14 22:18:43 +00:00
Mpc use now EventHandler
This commit is contained in:
parent
404ce3101a
commit
e923d06984
2624
LibMpc/Mpc.cs
2624
LibMpc/Mpc.cs
File diff suppressed because it is too large
Load Diff
@ -19,11 +19,11 @@ namespace Libmpc
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Is fired when a connection to a MPD server is established.
|
/// Is fired when a connection to a MPD server is established.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public event EventHandler OnConnected;
|
public event EventHandler Connected;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Is fired when the connection to the MPD server is closed.
|
/// Is fired when the connection to the MPD server is closed.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public event EventHandler OnDisconnected;
|
public event EventHandler Disconnected;
|
||||||
|
|
||||||
private static readonly string FIRST_LINE_PREFIX = "OK MPD ";
|
private static readonly string FIRST_LINE_PREFIX = "OK MPD ";
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ namespace Libmpc
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// If the connection to the MPD is connected.
|
/// If the connection to the MPD is connected.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool Connected { get { return (_tcpClient != null) && _tcpClient.Connected; } }
|
public bool IsConnected { get { return (_tcpClient != null) && _tcpClient.Connected; } }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The version of the MPD.
|
/// The version of the MPD.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -67,7 +67,7 @@ namespace Libmpc
|
|||||||
/// <param name="server">The IPEndPoint of the MPD server.</param>
|
/// <param name="server">The IPEndPoint of the MPD server.</param>
|
||||||
public MpcConnection(IPEndPoint server)
|
public MpcConnection(IPEndPoint server)
|
||||||
{
|
{
|
||||||
Connect(server);
|
Server = server;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The IPEndPoint of the MPD server.
|
/// The IPEndPoint of the MPD server.
|
||||||
@ -78,7 +78,7 @@ namespace Libmpc
|
|||||||
get { return _ipEndPoint; }
|
get { return _ipEndPoint; }
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (Connected)
|
if (IsConnected)
|
||||||
throw new AlreadyConnectedException();
|
throw new AlreadyConnectedException();
|
||||||
|
|
||||||
_ipEndPoint = value;
|
_ipEndPoint = value;
|
||||||
@ -86,15 +86,7 @@ namespace Libmpc
|
|||||||
ClearConnectionFields();
|
ClearConnectionFields();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
|
||||||
/// Connects to a MPD server.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="server">The IPEndPoint of the server.</param>
|
|
||||||
public void Connect(IPEndPoint server)
|
|
||||||
{
|
|
||||||
Server = server;
|
|
||||||
Connect();
|
|
||||||
}
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Connects to the MPD server who's IPEndPoint was set in the Server property.
|
/// Connects to the MPD server who's IPEndPoint was set in the Server property.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -104,7 +96,7 @@ namespace Libmpc
|
|||||||
if (_ipEndPoint == null)
|
if (_ipEndPoint == null)
|
||||||
throw new InvalidOperationException("Server IPEndPoint not set.");
|
throw new InvalidOperationException("Server IPEndPoint not set.");
|
||||||
|
|
||||||
if (Connected)
|
if (IsConnected)
|
||||||
throw new AlreadyConnectedException();
|
throw new AlreadyConnectedException();
|
||||||
|
|
||||||
|
|
||||||
@ -131,7 +123,7 @@ namespace Libmpc
|
|||||||
|
|
||||||
ReadResponse();
|
ReadResponse();
|
||||||
|
|
||||||
OnConnected?.Invoke(this, EventArgs.Empty);
|
Connected?.Invoke(this, EventArgs.Empty);
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Disconnects from the current MPD server.
|
/// Disconnects from the current MPD server.
|
||||||
@ -145,7 +137,7 @@ namespace Libmpc
|
|||||||
|
|
||||||
ClearConnectionFields();
|
ClearConnectionFields();
|
||||||
|
|
||||||
OnDisconnected?.Invoke(this, EventArgs.Empty);
|
Disconnected?.Invoke(this, EventArgs.Empty);
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Executes a simple command without arguments on the MPD server and returns the response.
|
/// Executes a simple command without arguments on the MPD server and returns the response.
|
||||||
@ -175,7 +167,7 @@ namespace Libmpc
|
|||||||
{
|
{
|
||||||
try { Disconnect(); }
|
try { Disconnect(); }
|
||||||
catch (Exception) { }
|
catch (Exception) { }
|
||||||
throw;
|
return null; // TODO: Create Null Object for MpdResponse
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -228,7 +220,7 @@ namespace Libmpc
|
|||||||
|
|
||||||
private void CheckConnected()
|
private void CheckConnected()
|
||||||
{
|
{
|
||||||
if (!Connected)
|
if (!IsConnected)
|
||||||
{
|
{
|
||||||
if (_autoConnect)
|
if (_autoConnect)
|
||||||
Connect();
|
Connect();
|
||||||
|
Loading…
Reference in New Issue
Block a user