示例#1
0
        /// <summary>
        /// 注册服务
        /// </summary>
        /// <param name="log"></param>
        private void registerServer(Log log)
        {
            HashString      name = log.Server.Name;
            ClientServerSet serverSet;

            Monitor.Enter(serverSetLock);
            try
            {
                if (serverSets.TryGetValue(name, out serverSet))
                {
                    serverSet.Add(log, isRegisterLoaded);
                }
                else
                {
                    serverSets.Add(name, serverSet = new ClientServerSet(log));
                }
            }
            finally { Monitor.Exit(serverSetLock); }
        }
示例#2
0
        /// <summary>
        /// TCP 客户端注册
        /// </summary>
        /// <param name="client">TCP 客户端</param>
        internal void Register(IClient client)
        {
            HashString      name = client.ServerName ?? string.Empty;
            ClientServerSet serverSet;

            Monitor.Enter(serverSetLock);
            try
            {
                if (serverSets.TryGetValue(name, out serverSet))
                {
                    serverSet.Add(client);
                }
                else
                {
                    serverSets.Add(name, serverSet = new ClientServerSet(client));
                    client.OnServerChange(null);
                }
            }
            finally { Monitor.Exit(serverSetLock); }
        }