Exemple #1
0
        /// <summary>
        /// TCP调用服务端
        /// </summary>
        /// <param name="attribute">配置信息</param>
        protected server(fastCSharp.code.cSharp.tcpServer attribute)
        {
            if (attribute == null)
            {
                log.Error.Throw(log.exceptionType.Null);
            }
            if (attribute.TcpRegisterName != null)
            {
                tcpRegisterClient = fastCSharp.net.tcp.tcpRegister.client.Get(attribute.TcpRegisterName);
                if (tcpRegisterClient == null)
                {
                    log.Error.Throw("TCP注册服务 " + attribute.TcpRegisterName + " 链接失败", null, false);
                }
                if (attribute.RegisterHost == null)
                {
                    attribute.RegisterHost = attribute.Host;
                }
                if (attribute.RegisterPort == 0)
                {
                    attribute.RegisterPort = attribute.Port;
                }
                fastCSharp.net.tcp.tcpRegister.registerState state = tcpRegisterClient.Register(attribute);
                if (state != fastCSharp.net.tcp.tcpRegister.registerState.Success)
                {
                    log.Error.Throw("TCP服务注册 " + attribute.ServiceName + " 失败 " + state.ToString(), null, false);
                }
                if (attribute.Port == 0)
                {
                    attribute.Port = attribute.RegisterPort;
                }
                log.Default.Add(attribute.ServiceName + " 注册 " + attribute.Host + ":" + attribute.Port.toString() + " => " + attribute.RegisterHost + ":" + attribute.RegisterPort.toString(), new System.Diagnostics.StackFrame(), false);
            }
            if (!attribute.IsServer)
            {
                log.Default.Add("配置未指明的TCP服务端 " + attribute.ServiceName, null, false);
            }
            this.attribute = attribute;
            if ((maxClientCount = attribute.MaxClientCount) <= 0)
            {
                maxClientCount = int.MaxValue;
            }
#if MONO
            //if (attribute.AcceptQueueSize > 30) attribute.AcceptQueueSize = 30;
            //else if (attribute.AcceptQueueSize < 4) attribute.AcceptQueueSize = 4;
#endif
        }
 /// <summary>
 /// TCP调用服务端
 /// </summary>
 /// <param name="attribute">配置信息</param>
 protected server(fastCSharp.code.cSharp.tcpServer attribute)
 {
     if (attribute == null) log.Error.Throw(log.exceptionType.Null);
     if (attribute.TcpRegisterName != null)
     {
         tcpRegisterClient = fastCSharp.net.tcp.tcpRegister.client.Get(attribute.TcpRegisterName);
         if (tcpRegisterClient == null) log.Error.Throw("TCP注册服务 " + attribute.TcpRegisterName + " 链接失败", true, false);
         fastCSharp.net.tcp.tcpRegister.registerState state = tcpRegisterClient.Register(attribute);
         if (state != fastCSharp.net.tcp.tcpRegister.registerState.Success) log.Error.Throw("TCP服务注册 " + attribute.ServiceName + " 失败 " + state.ToString(), true, false);
         log.Default.Add(attribute.ServiceName + " 注册 " + attribute.Host + ":" + attribute.Port.toString(), false, false);
     }
     if (!attribute.IsServer) log.Default.Add("配置未指明的TCP服务端 " + attribute.ServiceName, true, false);
     this.attribute = attribute;
 }