public static void LoadConfiguration() { string config; string configFile = string.Format("{0}", Assembly.GetEntryAssembly().Location.Replace("Bus.exe", "config.json")); if (!File.Exists(configFile)) { File.Create(configFile); } using (StreamReader configReader = new StreamReader(configFile)) { config = configReader.ReadToEnd(); try { Bus.Model = JsonConvert.DeserializeObject <BusConfig>(config); validConfig = true; } catch (Exception e) { Console.WriteLine(ConsoleFunctions.WriteWithColour(ConsoleColor.Red, "INVALID CONFIGURATION FILE")); BusLogger.LogException(e); validConfig = false; } finally { configReader.Close(); } } BusCCTV.CheckHDDUsage(); BusCCTV.CheckDriveHealth(); }
private static void ProcessCommand(WebSocketSession session, string value) { Command command = JsonConvert.DeserializeObject <Command>(value); if (command.Token != Bus.AuthToken) { BusLogger.LogException(new InvalidAuthTokenException("INVALID AUTHENTICATION TOKEN ERROR")); session.Send(JsonConvert.SerializeObject(CommandProcessor.CommandCallback("error_message", "An incorrect authentication key was provided"))); return; } session.Send(CommandProcessor.RunCommand(command)); session.Close(); }