Exemplo n.º 1
0
        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]);
        }
Exemplo n.º 2
0
        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]);
        }
Exemplo n.º 3
0
        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;
                }
            }
        }