Exemplo n.º 1
0
        public MpdTest(ITestOutputHelper testOutputHelper)
        {
            LogSettings.RegisterDefaultLogger <XUnitLogger>(LogLevels.Verbose, testOutputHelper);
            Task.Run(async() =>
            {
                var mpdInstances = (await MpdSocketClient.FindByZeroConfAsync()).ToList();
                foreach (var mpdInstance in mpdInstances)
                {
                    Log.Debug().WriteLine("Found {0} at {1}", mpdInstance.Key, mpdInstance.Value.AbsoluteUri);
                }

                _port = mpdInstances.First().Value.Port;
                _host = mpdInstances.First().Value.Host;
            }).Wait();
        }
Exemplo n.º 2
0
 public async Task InitializeAsync()
 {
     await Task.Run(async() =>
     {
         var mpdInstances = (await MpdSocketClient.FindByZeroConfAsync()).ToList();
         if (mpdInstances.Any())
         {
             _port = mpdInstances.First().Value.Port;
             _host = mpdInstances.First().Value.Host;
         }
         else
         {
             var portFromEnv = Environment.GetEnvironmentVariable("MPD_PORT");
             var hostFromEnv = Environment.GetEnvironmentVariable("MPD_HOST") ?? throw new ArgumentException(
                 "Configuration not found by ZeroConf and MPD_HOST not set in Environment");
             _port = portFromEnv == null ? 6600 : int.Parse(portFromEnv);
             _host = hostFromEnv;
         }
     });
 }