Beispiel #1
0
        public bool Start(HostControl hostControl)
        {
            if (ConfigSection.Default.Listeners.Any())
            {
                StartOptions options = new StartOptions();

                foreach (string url in ConfigSection.Default.Listeners.Select(x => x.Url))
                {
                    logger.InfoFormat("Listening on {0}", url);
                    options.Urls.Add(url);
                }

                // Start OWIN host
                webApp = WebApp.Start <WmBridge.Web.Startup>(options);
            }

            if (ConfigSection.Default.Autodiscovery.Any())
            {
                // Start autodiscovery service
                autodiscovery = Autodiscovery.StartResponder(ConfigSection.Default.Autodiscovery.Select(x => x.Url));
            }

            if (startActions != null)
            {
                startActions.ForEach(_ => _());
            }

            return(true);
        }
Beispiel #2
0
        public static Autodiscovery StartResponder(IEnumerable <string> urls)
        {
            var instance = new Autodiscovery(urls.Select(url => Encoding.UTF8.GetBytes(
                                                             JsonConvert.SerializeObject(new { url, machine = Environment.MachineName })))
                                             .ToArray());

            instance.BeginReceive();

            return(instance);
        }