Beispiel #1
0
 public CoreStates(
     Service.Servers servers,
     VgcApis.Models.Datas.CoreInfo coreInfo)
 {
     this.servers  = servers;
     this.coreInfo = coreInfo;
 }
Beispiel #2
0
        public bool AddServer(string config, string mark, bool quiet = false)
        {
            // first check
            if (IsServerExist(config))
            {
                return(false);
            }

            var coreInfo = new VgcApis.Models.Datas.CoreInfo
            {
                isInjectImport     = setting.CustomDefImportGlobalImport,
                isInjectSkipCNSite = setting.CustomDefImportBypassCnSite,
                customInbType      = setting.CustomDefImportMode,
                inbIp      = setting.CustomDefImportIp,
                inbPort    = setting.CustomDefImportPort,
                config     = config,
                customMark = mark,
            };

            var newServer = new Controllers.CoreServerCtrl(coreInfo);

            newServer.Run(cache, setting, configMgr, this);

            bool duplicated = true;

            lock (serverListWriteLock)
            {
                // double check
                if (!IsServerExist(config))
                {
                    coreServList.Add(newServer);
                    var idx = coreServList.Count();
                    newServer.GetCoreStates().SetIndexQuiet(idx);
                    AddNewMark(mark);
                    duplicated = false;
                }
            }

            if (duplicated)
            {
                newServer.Dispose();
                return(false);
            }

            BindEventsTo(newServer);
            if (!quiet)
            {
                newServer.GetConfiger().UpdateSummaryThen(() =>
                {
                    // UpdateSummaryThen will invoke OnServerPropertyChange.
                    InvokeEventOnServerCountChange(this, EventArgs.Empty);
                    RequireFormMainUpdate();
                });
            }
            setting.LazyGC();
            serverSaver.DoItLater();
            return(true);
        }
Beispiel #3
0
 public Configer(
     Services.Settings setting,
     Services.Cache cache,
     Services.ConfigMgr configMgr,
     VgcApis.Models.Datas.CoreInfo coreInfo)
 {
     this.configMgr = configMgr;
     this.setting   = setting;
     this.cache     = cache;
     this.coreInfo  = coreInfo;
 }
Beispiel #4
0
        public bool AddServer(string config, string mark, bool quiet = false)
        {
            // duplicate

            if (IsServerExist(config))
            {
                return(false);
            }

            var coreInfo = new VgcApis.Models.Datas.CoreInfo
            {
                config     = config,
                customMark = mark,
            };

            var newServer = new Controller.CoreServerCtrl(coreInfo);

            lock (serverListWriteLock)
            {
                coreServList.Add(newServer);
            }

            newServer.Run(cache, setting, configMgr, this);
            BindEventsTo(newServer);


            if (!quiet)
            {
                newServer.GetConfiger().UpdateSummaryThen(() =>
                {
                    InvokeEventOnRequireMenuUpdate(this, EventArgs.Empty);
                    RequireFormMainUpdate();
                });
            }

            setting.LazyGC();
            serverSaver.DoItLater();
            return(true);
        }
Beispiel #5
0
 public CoreServerCtrl(
     VgcApis.Models.Datas.CoreInfo coreInfo)
 {
     this.coreInfo = coreInfo;
 }