protected String getMediaServerIP(CpMediaServer _mediaServer)
{
if (_mediaServer == null)
return String.Empty;
this.writeLog(LogType.Info, "Auflösen der Raumfeld-MedienServer IP");
Uri url = new Uri(mediaServer.Location);
try
{
IPAddress address = IPAddress.Parse(url.Host);
return address.ToString();
}
catch (Exception e)
{
this.writeLog(LogType.Warning, String.Format("IP-Adresse konnte nicht aufgelöst werden. Host: {0} Suche über DNS", url.Host), e);
}
try
{
IPHostEntry hostEntry = Dns.GetHostEntry(url.Host);
return hostEntry.AddressList[0].ToString();
}
catch (Exception e)
{
this.writeLog(LogType.Error, String.Format("IP-Adresse konnte nicht per DNS aufgelöst werden. Host: {0}", url.Host), e);
// this is a fatal error! App hast to crash!
throw new Exception(Global.getCrashInfo());
}
}