Ejemplo n.º 1
0
        internal DCClient_Star(ClientCfg clientCfg, string id)
        {
            this.id      = id;
            this.guidStr = Guid.NewGuid().ToString();         //Global.Encoding.GetString(guid);
            this.guid    = Global.Encoding.GetBytes(guidStr); //Guid.NewGuid().ToByteArray();
            cfg          = clientCfg;
            init();

            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
        }
Ejemplo n.º 2
0
        private static ClientCfg getClientCfg(string configName)
        {
            ClientCfg cc  = new ClientCfg();
            IConfig   cfg = cs.Configs[configName];

            cc.ServerR     = cfg.Get("ServerR");
            cc.ServerS     = cfg.Get("ServerS");
            cc.ClientID    = cfg.Get("ClientID");
            cc.BindingType = cfg.Get("BindingType");
            return(cc);
        }
Ejemplo n.º 3
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]);
        }
Ejemplo n.º 4
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]);
        }
Ejemplo n.º 5
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;
                }
            }
        }