Beispiel #1
0
 /// <summary>
 /// 释放资源
 /// </summary>
 public override void Dispose()
 {
     base.Dispose();
     if (tcpRegisterClient != null)
     {
         tcpRegisterClient.Remove(this);
         tcpRegisterClient = null;
     }
 }
Beispiel #2
0
 /// <summary>
 /// TCP 内部服务客户端
 /// </summary>
 /// <param name="attribute">TCP服务调用配置</param>
 /// <param name="log">日志接口</param>
 public Client(ServerAttribute attribute, ILog log)
     : base(attribute, log, int.MaxValue)
 {
     if (attribute.TcpRegisterName != null)
     {
         tcpRegisterClient = AutoCSer.Net.TcpRegister.Client.Get(attribute.TcpRegisterName, Log);
         tcpRegisterClient.Register(this);
     }
 }
Beispiel #3
0
 /// <summary>
 /// TCP 内部服务客户端
 /// </summary>
 /// <param name="attribute">TCP服务调用配置</param>
 /// <param name="onCustomData">自定义数据包处理</param>
 /// <param name="log">日志接口</param>
 /// <param name="clientRoute">TCP 客户端路由</param>
 internal Client(ServerAttribute attribute, Action <SubArray <byte> > onCustomData, ILog log, AutoCSer.Net.TcpServer.ClientLoadRoute <ClientSocketSender> clientRoute)
     : base(attribute, onCustomData, log)
 {
     this.clientRoute = clientRoute;
     if (attribute.TcpRegisterName != null)
     {
         tcpRegisterClient = AutoCSer.Net.TcpRegister.Client.Get(attribute.TcpRegisterName, Log);
         tcpRegisterClient.Register(this);
     }
 }
Beispiel #4
0
 /// <summary>
 /// TCP 内部服务客户端
 /// </summary>
 /// <param name="attribute">TCP服务调用配置</param>
 /// <param name="log">日志接口</param>
 /// <param name="clientRoute">TCP 客户端路由</param>
 internal Client(ServerAttribute attribute, ILog log, AutoCSer.Net.TcpServer.ClientLoadRoute <ClientSocketSender> clientRoute)
     : base(attribute, log)
 {
     this.clientRoute = clientRoute;
     if (attribute.TcpRegisterName != null)
     {
         tcpRegisterClient = AutoCSer.Net.TcpRegister.Client.Get(attribute.TcpRegisterName, Log);
         tcpRegisterClient.Register(this);
     }
 }
Beispiel #5
0
 /// <summary>
 /// 获取 TCP 内部注册服务客户端
 /// </summary>
 /// <typeparam name="serverAttributeType"></typeparam>
 /// <param name="attribute"></param>
 /// <param name="tcpRegisterName"></param>
 /// <param name="tcpRegisterClient"></param>
 /// <returns></returns>
 internal bool GetRegisterClient <serverAttributeType>(serverAttributeType attribute, string tcpRegisterName, ref TcpRegister.Client tcpRegisterClient)
     where serverAttributeType : ServerBaseAttribute, TcpRegister.IServerAttribute
 {
     if (tcpRegisterName != null)
     {
         tcpRegisterClient = TcpRegister.Client.Get(tcpRegisterName, Log);
         if (tcpRegisterClient == null)
         {
             Log.Add(AutoCSer.Log.LogType.Error, "TCP 内部注册服务 " + tcpRegisterName + " 客户端获取失败");
             return(false);
         }
         if (attribute.ClientRegisterHost == null)
         {
             attribute.ClientRegisterHost = attribute.Host;
         }
         if (attribute.ClientRegisterPort == 0)
         {
             attribute.ClientRegisterPort = attribute.Port;
         }
         if (attribute.ClientRegisterPort == 0)
         {
             if (tcpRegisterClient.GetPort(attribute))
             {
                 Port = attribute.Port;
             }
             else
             {
                 Log.Add(AutoCSer.Log.LogType.Error, "TCP 内部服务 " + attribute.ServerName + " 端口获取失败");
                 return(false);
             }
         }
     }
     return(true);
 }
Beispiel #6
0
 /// <summary>
 /// 获取 TCP 内部注册服务客户端
 /// </summary>
 /// <param name="attribute"></param>
 /// <param name="tcpRegisterName"></param>
 /// <param name="tcpRegisterClient"></param>
 /// <returns></returns>
 internal bool GetRegisterClient(ServerBaseAttribute attribute, string tcpRegisterName, ref TcpRegister.Client tcpRegisterClient)
 {
     if (tcpRegisterName != null)
     {
         tcpRegisterClient = TcpRegister.Client.Get(tcpRegisterName, Log);
         if (tcpRegisterClient == null)
         {
             Log.Add(AutoCSer.Log.LogType.Error, "TCP 内部注册服务 " + tcpRegisterName + " 客户端获取失败");
             return(false);
         }
         if (attribute.ClientRegisterHost == null)
         {
             attribute.ClientRegisterHost = attribute.Host;
         }
         if (attribute.ClientRegisterPort == 0)
         {
             attribute.ClientRegisterPort = attribute.Port;
         }
     }
     return(true);
 }