/// <summary> /// TCP调用服务端 /// </summary> /// <param name="attribute">配置信息</param> /// <param name="verify">验证接口</param> /// <param name="isStart">是否启动连接</param> public tcpClient(fastCSharp.setup.cSharp.tcpServer attribute, fastCSharp.setup.cSharp.tcpBase.ITcpVerifyClient verify = null, bool isStart = true) { this.attribute = attribute; if (attribute.TcpRegisterName != null) { if (fastCSharp.setup.tcpRegister.client.Get(attribute.TcpRegisterName).GetRegister(attribute)) { errorServiceName = null; } else { if (errorServiceName != attribute.ServiceName) { log.Default.Add(attribute.ServiceName + " 未找到注册服务信息", false, false); } errorServiceName = attribute.ServiceName; } } this.verify = verify; data = new byte[sizeof(long)]; if (isStart) { start(); } }
/// <summary> /// TCP调用服务端 /// </summary> /// <param name="attribute">配置信息</param> protected tcpServerBase(fastCSharp.setup.cSharp.tcpServer attribute) { if (attribute == null) { log.Default.Throw(log.exceptionType.Null); } if (attribute.TcpRegisterName != null) { fastCSharp.setup.tcpRegister.client client = fastCSharp.setup.tcpRegister.client.Get(attribute.TcpRegisterName); if (client == null) { log.Default.Throw("TCP注册服务 " + attribute.TcpRegisterName + " 链接失败", true, false); } fastCSharp.setup.tcpRegister.registerState state = client.Register(attribute); if (state != fastCSharp.setup.tcpRegister.registerState.Success) { log.Default.Throw("TCP服务注册 " + attribute.ServiceName + " 失败 " + state.ToString(), true, false); } log.Default.Add(attribute.ServiceName + " 注册 " + attribute.Host + ":" + attribute.Port.toString()); } if (!attribute.IsServer) { log.Default.Add("配置未指明的TCP服务端", true, false); } this.attribute = attribute; }
/// <summary> /// TCP调用服务端 /// </summary> /// <param name="attribute">TCP调用服务器端配置信息</param> /// <param name="verify">TCP验证实例</param> public @TypeNameAsynchronous(fastCSharp.setup.cSharp.tcpServer attribute = null, fastCSharp.setup.cSharp.tcpBase.ITcpVerifyAsynchronous verify = null) : base(attribute ?? fastCSharp.setup.cSharp.tcpServer.GetConfig("@Attribute.ServiceName", typeof(@type.FullName)), verify /*IF:Attribute.VerifyType*/ ?? new @TcpVerifyType() /*IF:Attribute.VerifyType*/) { _value_.SetTcpServer(this); #region FROMNAME OnCommands #endregion FROMNAME OnCommands }
/// <summary> /// TCP调用服务端 /// </summary> /// <param name="attribute">配置信息</param> /// <param name="verify">TCP客户端验证接口</param> public tcpServer(fastCSharp.setup.cSharp.tcpServer attribute, verifyType verify) : base(attribute) { if (verify == null) { log.Default.Add("缺少TCP客户端验证接口", true, false); } this.verify = verify; }
/// <summary> /// 客户端TCP调用池 /// </summary> /// <param name="attribute">TCP调用服务器端配置信息</param> /// <param name="isStart">是否启动连接</param> /// <param name="serviceName">服务名称</param> /// <param name="verify">TCP验证实例</param> public clientPool(fastCSharp.setup.cSharp.tcpServer attribute, bool isStart, string serviceName = null, fastCSharp.setup.cSharp.tcpBase.ITcpVerifyClient verify = null) { this.attribute = attribute; this.serviceName = serviceName; this.verify = verify; this.isStart = isStart; maxCount = attribute.MaxClientCount < 2 ? 2 : attribute.MaxClientCount; fastCSharp.threading.task.Default.Add(createClient, onClientError); }
/// <summary> /// TCP调用服务端 /// </summary> /// <param name="attribute">TCP调用服务器端配置信息</param> /// <param name="verify">TCP验证实例</param> public @ServiceName(fastCSharp.setup.cSharp.tcpServer attribute = null, fastCSharp.setup.cSharp.tcpBase.ITcpVerify verify = null) : base(attribute ?? fastCSharp.setup.cSharp.tcpServer.GetConfig("@ServiceName"), verify /*IF:ServiceAttribute.VerifyType*/ ?? new @TcpVerifyType() /*IF:ServiceAttribute.VerifyType*/) { #region NAME OnCommands list <keyValue <hashBytes, keyValue <action <socket, int>, bool> > > .unsafer onCommands = new list <keyValue <hashBytes, keyValue <action <socket, int>, bool> > >(@MethodIndexs.Length + 1).Unsafer; onCommands.Add(new keyValue <hashBytes, keyValue <action <socket, int>, bool> >(closeCommandData, new keyValue <action <socket, int>, bool>(new action <socket, int>(close), false))); #region LOOP MethodIndexs onCommands.Add(new keyValue <hashBytes, keyValue <action <socket, int>, bool> >(formatMethodKeyName("@Method.MethodKeyFullName"), new keyValue <action <socket, int>, bool>(@MethodIndexName, @IsInputParameter))); #endregion LOOP MethodIndexs this.onCommands = new staticDictionary <hashBytes, keyValue <action <socket, int>, bool> >(onCommands.List); #endregion NAME OnCommands }
static tcpCallSegmentation() { defaultTcpServer = fastCSharp.setup.cSharp.tcpServer.GetConfig("tcpCallSegmentation"); defaultTcpServer.IsServer = false; }
/// <summary> /// TCP调用服务端 /// </summary> /// <param name="attribute">TCP调用服务器端配置信息</param> /// <param name="verify">TCP验证实例</param> public @ServiceNameAsynchronous(fastCSharp.setup.cSharp.tcpServer attribute = null, fastCSharp.setup.cSharp.tcpBase.ITcpVerifyAsynchronous verify = null) : base(attribute ?? fastCSharp.setup.cSharp.tcpServer.GetConfig("@ServiceName"), verify /*IF:ServiceAttribute.VerifyType*/ ?? new @TcpVerifyType() /*IF:ServiceAttribute.VerifyType*/) { #region FROMNAME OnCommands #endregion FROMNAME OnCommands }
/// <summary> /// TCP调用客户端 /// </summary> /// <param name="attribute">TCP调用服务器端配置信息</param> /// <param name="verify">TCP验证实例</param> /// <param name="isStart">是否启动连接</param> public tcpServerSegmentation(fastCSharp.setup.cSharp.tcpServer attribute = null, fastCSharp.setup.cSharp.tcpBase.ITcpVerifyClient verify = null, bool isStart = true) { _tcpClient_ = new fastCSharp.net.tcpClient(attribute ?? fastCSharp.setup.cSharp.tcpServer.GetConfig("tcpServerSegmentation", typeof(fastCSharp.testCase.tcpServerSegmentation)), verify, isStart); }