private static void Main() { XmlConfigurator.Configure(); try { var settings = SimpleSettings.Create("settings"); CryptoConfig.AddAlgorithm(typeof(RHHE), RHHE.Name); var sleepPeriod = int.Parse(settings.GetValue("sleep")); var ttl = int.Parse(settings.GetValue("ttl")); var server = PrepareServer(settings); var wsServer = PrepareWsServer(settings); SecretHolder.Init(settings.GetValue("secret")); CredentialsHolder.Init(settings.GetValue("credentials"), sleepPeriod); PointHolder.Init(settings.GetValue("points"), sleepPeriod, ttl, (point, msg) => wsServer.BroadcastAsync(point, msg, CancellationToken.None)); Task .WhenAll( server.AcceptLoopAsync(CancellationToken.None), wsServer.AcceptLoopAsync(CancellationToken.None) ) .Wait(); } catch (Exception ex) { Console.Error.WriteLine(ex); Log.Fatal("Unexpected exception", ex); Environment.Exit(ex.HResult == 0 ? ex.HResult : -1); } }