Exemplo n.º 1
0
        public Server(String serverDir, String configKey, Config multiAdminCfg, String mainConfigLocation, String configChain, bool multiMode)
        {
            this.multiMode     = multiMode;
            MainConfigLocation = mainConfigLocation;
            ConfigKey          = configKey;
            ConfigChain        = configChain;
            ServerDir          = serverDir;
            session_id         = Utils.GetUnixTime().ToString();
            Commands           = new Dictionary <string, ICommand>();
            Features           = new List <Feature>();
            tick                = new List <IEventTick>();
            MultiAdminCfg       = multiAdminCfg;
            StartDateTime       = Utils.GetDate();
            maLogLocation       = LogFolder + StartDateTime + "_MA_output_log.txt";
            stopping            = false;
            InitialRoundStarted = false;
            readerThread        = new Thread(new ThreadStart(() => InputThread.Write(this)));
            printerThread       = new Thread(new ThreadStart(() => OutputThread.Read(this)));

            // Register all features
            RegisterFeatures();
            // Load config
            serverConfig = new Config(ServerDir + Path.DirectorySeparatorChar + ConfigKey + Path.DirectorySeparatorChar + "config.txt");
            // Enable / Disable MultiAdmin Optimizations
            runOptimized = serverConfig.GetBoolean("enable_multiadmin_optimizations", true);
            // Init features
            InitFeatures();
            // Start the server and threads
            if (StartServer())
            {
                readerThread.Start();
                printerThread.Start();
                MainLoop();
            }
        }
Exemplo n.º 2
0
 protected override void Dispose(bool disposing)
 {
     StopThread = true;
     InputPoolingThread?.Abort();
     OutputThread?.Abort();
     Device.CloseDevice();
     Device.Dispose();
     base.Dispose(disposing);
 }