Example #1
0
        protected override void OnStart(string[] args)
        {
            logger.Debug($"{ LOG_PREFIX } Load configuration from RedFox.config.json");

            try
            {
                // Load configuration values
                config = JObject.Parse(
                    File.ReadAllText(
                        Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + @"/RedFox.config.json"));

                logger.Debug($"{ LOG_PREFIX } Configuration loaded succesfully");
            }
            catch (Exception e)
            {
                logger.Error($"{ LOG_PREFIX } Error while trying to load configuration; { e.Message }");
                logger.Debug(e.StackTrace);
            }

            // Try ... Catch is handled in the method
            ComposeExtensions();

            try
            {
                // Set up messaging
                logger.Debug($"{ LOG_PREFIX } Set up messaging");

                // Initialize the message client
                messageClient = Shared.Extensions.Instance.MessageClient.Value;
                messageClient.Init(config["Server"]["IPv4"].Value <string>());

                // React on incoming messages
                messageClient.MessageReceived += MessageClient_MessageReceived;
                messageClient.Listen();
            }
            catch (Exception e)
            {
                logger.Error($"{ LOG_PREFIX } Error while initializing messaging client");
                logger.Debug(e.Message);
                logger.Debug(e.StackTrace);
            }

            // Try ... Catch is handled in the method
            RegisterServer(config);
        }