private void InitialiseServerInformation() { Debug.Assert(messengerOptions.LocalCIDR != null); try { var list = NetInfo.GetMatchingIPV4Addresses(messengerOptions.LocalCIDR); if (list.Count() > 1) { log.Warning($"Multiple local ipaddresses: {(string.Join(", ", list.Select(l => l.ToString()).ToArray()))}, cidr is {messengerOptions.LocalCIDR}, config error?"); } var ipAddress = list.First(); si = new MusicServerInformation { MachineName = Environment.MachineName.ToLower(), ProcessId = System.Diagnostics.Process.GetCurrentProcess().Id, //Url = $"http://{ipAddress.ToString()}:{musicServerOptions.Port}" }; if (environment.IsDevelopment()) { // in development, I use IISExpress which by default only listens to "localhost" si.Url = $"http://localhost:{musicServerOptions.Port}"; } else { si.Url = $"http://{ipAddress.ToString()}:{musicServerOptions.Port}"; } log.Information($"music server url is {si.Url}"); } catch (Exception xe) { //Debugger.Break(); log.Error(xe); } }
public Receiver(IOptions <MusicConfiguration> musicConfigOptions, DeviceManagerFactory dmf, Messenger messenger, ILoggerFactory loggerFactory) : base(loggerFactory) { this.musicConfig = musicConfigOptions.Value; this.dmf = dmf; this.messenger = messenger; serverInformation = new MusicServerInformation(); machineName = Environment.MachineName.ToLower(); var list = NetInfo.GetMatchingIPV4Addresses(musicConfig.LocalCIDR); currentIpAddress = list.First().ToString(); }