1
0
mirror of https://github.com/ZetaKebab/MpcNET.git synced 2024-09-16 05:30:09 +00:00
MpcNET/LibMpcApp/Program.cs

84 lines
2.5 KiB
C#
Raw Normal View History

2016-12-02 14:19:18 +00:00
using System;
using System.Net;
using LibMpc;
namespace LibMpcApp
{
2016-12-05 08:46:44 +00:00
/// <summary>
/// Simple console app to test commands and parsed responses.
/// </summary>
2016-12-02 14:19:18 +00:00
public class Program
{
public static void Main(string[] args)
{
var mpc = new Mpc(new IPEndPoint(IPAddress.Loopback, 6600));
var connected = mpc.ConnectAsync().GetAwaiter().GetResult();
if (connected)
{
Console.WriteLine("Connected to MPD.");
2016-12-02 14:19:18 +00:00
StartReadCommands(mpc);
}
else
{
Console.WriteLine("Could not connect to MPD.");
2016-12-02 14:19:18 +00:00
}
mpc.DisconnectAsync().GetAwaiter().GetResult();
2016-12-02 14:19:18 +00:00
}
private static void StartReadCommands(Mpc mpc)
{
2016-12-05 08:46:44 +00:00
int userInput = 0;
while ((userInput = DisplayMenu()) != 99)
{
2016-12-05 08:46:44 +00:00
var response = new object();
switch (userInput)
{
case 11:
response = mpc.SendAsync(new Commands.Output.DisableOutput(0)).GetAwaiter().GetResult();
break;
case 12:
response = mpc.SendAsync(new Commands.Output.EnableOutput(0)).GetAwaiter().GetResult();
break;
case 13:
response = mpc.SendAsync(new Commands.Output.Outputs()).GetAwaiter().GetResult();
break;
case 24:
response = mpc.SendAsync(new Commands.Reflection.TagTypes()).GetAwaiter().GetResult();
break;
}
2016-12-05 08:46:44 +00:00
Console.WriteLine("Response: ");
Console.WriteLine(response);
}
2016-12-02 14:19:18 +00:00
}
2016-12-05 08:46:44 +00:00
static public int DisplayMenu()
{
Console.WriteLine();
Console.WriteLine("Commands: ");
// Ouput
Console.WriteLine();
Console.WriteLine("11. disableoutput 0");
Console.WriteLine("12. enableoutput 0");
Console.WriteLine("13. outputs");
// Reflection
Console.WriteLine();
Console.WriteLine("24. tagtypes");
// Database
Console.WriteLine();
2016-12-05 08:46:44 +00:00
Console.WriteLine("99. Exit");
Console.WriteLine();
var result = Console.ReadLine();
return Convert.ToInt32(result);
}
2016-12-02 14:19:18 +00:00
}
}