public static DCClient Instance(string clientId, ClientCfg clientCfg) { string key = string.Concat("[", clientId, "][", clientCfg.ToString(), "]"); if (!clients.ContainsKey(key)) { lock (clientsLocker) { if (!clients.ContainsKey(key)) { DCClient client = new DCClient_Star(clientCfg, clientId); client.key = key; clients.Add(key, client); } } } return(clients[key]); }
public static DCClient Instance(string clientId, string configName) { string key = string.Concat(clientId, ":", configName); if (!clients.ContainsKey(key)) { lock (clientsLocker) { if (!clients.ContainsKey(key)) { ClientCfg cc = getClientCfg(configName); DCClient client = new DCClient_Star(cc, clientId); client.key = key; clients.Add(key, client); } } } return(clients[key]); }
static void file_Changed(string path) { DCLogger.LogInfo(string.Format("Config file changed..[{0}]", path)); cs.Reload(); foreach (string key in clients.Keys) { string clientId = key.Split(':')[0]; string configName = key.Split(':')[1]; ClientCfg cc = getClientCfg(configName); if (!cc.Equals(clients[key].Cfg)) { DCClient oldClt = clients[key]; DCClient client = new DCClient_Star(cc, clientId); clients[key] = client; //innerCtrl.Send(oldClt.guid, Global.DC_CTRL_EXIT); //System.Threading.Thread.Sleep(100); oldClt.Dispose(); oldClt = null; } } }