コード例 #1
0
 /// <summary>
 /// TCP 服务更新
 /// </summary>
 /// <param name="serverSet"></param>
 private void onServerChange(ServerSet serverSet)
 {
     foreach (IClient client in clients)
     {
         client.OnServerChange(serverSet);
     }
 }
コード例 #2
0
 /// <summary>
 /// TCP 服务更新
 /// </summary>
 /// <param name="serverSet"></param>
 private void onServerChange(ServerSet serverSet)
 {
     if (serverSet.Server == null)
     {
         serverSet = null;
     }
     foreach (IClient client in clients)
     {
         client.OnServerChange(serverSet);
     }
 }
コード例 #3
0
 private bool checkRegister(long ticks, ServerInfo server)
 {
     if (ticks == this.ticks && server != null && server.HostToIpAddress())
     {
         server.IsCheckRegister = true;
         HashString serverName = server.Name, ipHash = config.IsPort(server.Port) ? (HashString)server.Host : default(HashString);
         ServerSet  serverSet;
         Ports      ports;
         Log        log = new Log {
             Type = LogType.RegisterServer, Server = server
         };
         bool   isNewLog;
         object arrayLock = clientPool.ArrayLock;
         Monitor.Enter(arrayLock);
         if (clientPool.Array[server.ClientIndex].Identity == server.ClientIdentity)
         {
             try
             {
                 if (serverSets.TryGetValue(serverName, out serverSet))
                 {
                     isNewLog = serverSet.Check(log);
                 }
                 else
                 {
                     serverSets.Add(serverName, serverSet = new ServerSet(log));
                     isNewLog = true;
                 }
                 isNew |= isNewLog;
                 if (isNewLog)
                 {
                     onLog(log);
                     if (config.IsPort(server.Port))
                     {
                         if (!ipPorts.TryGetValue(ipHash, out ports))
                         {
                             ipPorts.Add(ipHash, ports = new Ports(config));
                         }
                         ports.Set(server.Port);
                     }
                 }
             }
             finally { Monitor.Exit(arrayLock); }
             return(true);
         }
         Monitor.Exit(arrayLock);
     }
     return(false);
 }
コード例 #4
0
        internal void Add(ServerLog log)
        {
            bool isMainChanged;

            if (serverSet == null)
            {
                serverSet     = new ServerSet(log);
                isMainChanged = true;
            }
            else
            {
                serverSet.Add(log, out isMainChanged);
            }
            if (isMainChanged)
            {
                onServerChange(serverSet);
            }
        }
コード例 #5
0
 internal void Add(Log log, bool isLoaded)
 {
     if (serverSet == null)
     {
         serverSet = new ServerSet(log);
     }
     else if (serverSet.Server == null)
     {
         serverSet.Server = log;
     }
     else
     {
         serverSet.Add(log);
     }
     if (isLoaded)
     {
         onServerChange(serverSet);
     }
 }
コード例 #6
0
ファイル: Server.cs プロジェクト: zhangb12465/AutoCSer
        protected virtual bool appendLog(ServerLog server)
        {
            if (server != null && server.HostToIpAddress())
            {
                ServerSet serverSet;
                bool      isLog = true;
                switch (server.LogType)
                {
                case LogType.RegisterServer:
                    HashString serverName = server.Name;
                    if (serverSets.TryGetValue(serverName, out serverSet))
                    {
                        bool isMainChanged;
                        isLog = serverSet.Add(server, out isMainChanged);
                    }
                    else
                    {
                        serverSets.Add(serverName, serverSet = new ServerSet(server));
                    }
                    break;

                case LogType.RemoveServer:
                    if (serverSets.TryGetValue(server.Name, out serverSet))
                    {
                        serverSet.Remove(server);
                    }
                    break;

                default:
                    AutoCSer.Log.Pub.Log.Add(Log.LogType.Error, "未知的 TCP 内部注册服务更新日志类型 " + server.toJson());
                    return(false);
                }
                if (isLog)
                {
                    onLog(server);
                    return(true);
                }
            }
            return(false);
        }
コード例 #7
0
 /// <summary>
 /// 客户端 TCP 服务信息集合
 /// </summary>
 /// <param name="log"></param>
 internal ClientServerSet(Log log)
 {
     serverSet = new ServerSet(log);
 }
コード例 #8
0
 internal void Set(string name, ServerSet serverSet)
 {
     Name    = name;
     Server  = serverSet.Server.Server;
     Servers = serverSet.Servers.Length == 0 ? null : serverSet.Servers.GetArray(value => value.Server);
 }