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); }
void ServerTrackingUpdateWorker( Controllers.CoreServerCtrl coreServCtrl, bool isStart) { var config = coreServCtrl?.GetConfiger()?.GetConfig(); var curTrackerSetting = configMgr.GenCurTrackerSetting( coreServList.AsReadOnly(), config ?? string.Empty, isStart); setting.SaveServerTrackerSetting(curTrackerSetting); return; }