internal DispatchServer(iniconfig cfg) { Calls = new Dictionary <Guid, string>(); this.cfg = cfg; perms = Permissions.Get; Port = this.cfg.GetIntValue("server", "port", 33333); Log.WriteLine("Setting port to " + Port); Start(); }
private void InitializeComponents() { callbacks = new ConcurrentQueue <Action>(); officers = new StorageManager <Officer>(); assignments = new List <Assignment>(); ofcAssignments = new Dictionary <Officer, Assignment>(); commands = new Dictionary <string, CommandAttribute>(); bolos = new StorageManager <Bolo>(); civs = new StorageManager <Civilian>(); civVehs = new StorageManager <CivilianVeh>(); currentCalls = new List <EmergencyCall>(); cfg = new iniconfig(Function.Call <string>(Hash.GET_CURRENT_RESOURCE_NAME), "settings.ini"); Permissions.SetInformation("permissions.perms", Function.Call <string>(Hash.GET_CURRENT_RESOURCE_NAME)); perms = Permissions.Get; perms.Refresh(); if (cfg.GetIntValue("server", "enable", 0) == 1) { ThreadPool.QueueUserWorkItem(x => server = new DispatchServer(cfg), null); Log.WriteLine("Starting DISPATCH server"); } else { Log.WriteLine("Not starting DISPATCH server"); } if (cfg.GetIntValue("database", "enable", 0) == 1) { Log.WriteLine("Reading database..."); data = new Database(); civs = data.Read <Civilian>("dsciv.db") ?? new StorageManager <Civilian>(); civVehs = data.Read <CivilianVeh>("dsveh.db") ?? new StorageManager <CivilianVeh>(); Log.WriteLine("Read and set database"); ThreadPool.QueueUserWorkItem(async x => { await Delay(15000); while (true) { #if DEBUG Log.WriteLine("Writing current information to database"); #else Log.WriteLineSilent("Writing current information to database"); #endif data.Write(civs, "dsciv.db"); data.Write(civVehs, "dsveh.db"); await Delay(180 * 1000); } }); } else { Log.WriteLine("Not start database"); } }