Example #1
0
 private static void VoidRawGet(string endpoint, WebHeaderCollection headers)
 {
     try {
         Utility.Request.RawGet(Consts.Endpoints.juggler + endpoint, headers);
     } catch (Exception ex) {
         Log.Crash($"Local request failed. {ex.Message}");
         return;
     }
 }
Example #2
0
 public static void Run(Action runnable, CancellationToken ct, string botName = "EXTRA")
 {
     taskLog.Info(botName, $"[{runnable.Method}] started");
     Task.Run(() => {
         try {
             runnable();
         } catch (Exception e) {
             taskLog.Crash($"Message: {e.Message} \n {e.StackTrace}");
         }
     }, ct).ContinueWith(tsk => taskLog.Info(botName, $"[{runnable.Method}] ended"));
 }
Example #3
0
 private void Respond(HttpListenerContext context, System.Reflection.MethodInfo method, object container, object[] ParsedParams)
 {
     try {
         Respond(context, (JObject)method.Invoke(container, ParsedParams));
     } catch (System.Reflection.TargetInvocationException ex) {
         var aex = ex.InnerException as ArgumentException;
         var eex = ex.InnerException as Exception;
         if (aex != null)
         {
             Respond(context, new JObject {
                 ["success"] = false,
                 ["error"]   = aex.Message
             });
         }
         else
         {
             Respond(context, new JObject {
                 ["success"]   = false,
                 ["exception"] = eex.Message,
                 ["trace"]     = eex.StackTrace
             });
         }
     } catch (Exception ex) {
         logger.Crash($"Respond threw an exception. {ex.Message}. Trace: {ex.StackTrace}");
     }
 }
Example #4
0
 public bool ReloadConfig()
 {
     try {
         coreConfig = JsonConvert.DeserializeObject <CoreConfig>(Request.Get(Consts.Endpoints.ServerConfig));
         foreach (var bot in coreConfig.Bots)
         {
             TokenCache[bot.Username] = bot.TradeToken;
         }
         return(true);
     } catch {
         logger.Crash("Could not reload config");
         return(false);
     }
 }
Example #5
0
        public Core(int port = 4345)
        {
            try {
                server = new HttpListener();
                logger = new NewMarketLogger("Core");
                server.Prefixes.Add($"http://+:{port}/");
                Init();
                VK.Init();

                unstickeredCache = new EmptyStickeredDatabase();
                unstickeredCache.LoadFromArray(File.ReadAllLines(Path.Combine("assets", "emptystickered.txt")));

                logger.Nothing("Starting!");
                ReloadConfig();
                server.Start();
                logger.Nothing("Started!");
                Task.Run((Action)Listen);
                Task.Run((Action)BackgroundCheck);
                Task.Run((Action)UnstickeredDumper);
                //Task.Run((Action)DBHitProvider);
            } catch (Exception ex) {
                logger.Crash($"Message: {ex.Message}. Trace: {ex.StackTrace}");
            }
        }