/// <summary> /// 测试线程 /// </summary> /// <param name="form"></param> public testClient(form form) { this.form = form; OnSend = onSend; Client = new tcpPerformanceServer.performanceServer.tcpClient(form.tcpServer, null); if (Client.TcpCommandClient.StreamSocket != null) { CommandClient = Client.TcpCommandClient; } else { pub.Dispose(ref Client); throw new Exception(); } }
public bool Verify(fastCSharp.net.tcp.commandLoadBalancingServer.commandClient client) #endif { #if NOJIT fastCSharp.net.tcp.commandLoadBalancingServer.commandClient client = (fastCSharp.net.tcp.commandLoadBalancingServer.commandClient)clientObject; #endif fastCSharp.net.tcp.timeVerifyServer.input input = new fastCSharp.net.tcp.timeVerifyServer.input(); fastCSharp.net.tcp.commandClient commandClient = client.TcpCommandClient; fastCSharp.code.cSharp.tcpServer attribute = commandClient.Attribute; string verifyString = attribute.VerifyString; if (verifyString == null) { return(client.Verify(ref input).Value.Ret); } ulong markData = 0; if (attribute.IsMarkData) { markData = attribute.VerifyHashCode; } input.ticks = date.UtcNow.Ticks; do { input.randomPrefix = random.Default.SecureNextULongNotZero(); while (input.randomPrefix == markData) { input.randomPrefix = random.Default.SecureNextULongNotZero(); } commandClient.ReceiveMarkData = attribute.IsMarkData ? markData ^ input.randomPrefix : 0UL; commandClient.SendMarkData = 0; input.MD5(verifyString); long lastTicks = input.ticks; fastCSharp.net.returnValue <fastCSharp.net.tcp.timeVerifyServer.output> isVerify = client.Verify(ref input); if (isVerify.Value.Ret) { commandClient.SendMarkData = commandClient.ReceiveMarkData; return(true); } if (isVerify.Type != fastCSharp.net.returnValue.type.Success || input.ticks <= lastTicks) { return(false); } ++input.ticks; log.Error.Add("TCP客户端验证时间失败重试", null, false); }while (true); }
/// <summary> /// 忽略TCP分组 /// </summary> /// <param name="groupId">分组标识</param> /// <returns>是否调用成功</returns> public fastCSharp.net.returnValue.type TcpIgnoreGroup(int groupId) { fastCSharp.net.tcp.commandClient client = TcpCommandClient; return(client == null ? fastCSharp.net.returnValue.type.ClientDisposed : client.IgnoreGroup(groupId)); }
public tcpClient(fastCSharp.code.cSharp.tcpServer attribute = null, fastCSharp.code.cSharp.tcpBase.ITcpClientVerify verify = null) #endif { tcpCommandClient = new fastCSharp.net.tcp.commandClient <tcpClient>(attribute ?? fastCSharp.code.cSharp.tcpServer.GetConfig("tcpPerformance", typeof(fastCSharp.demo.tcpPerformanceServer.performanceServer)), 28, verify); }
public tcpClient(fastCSharp.code.cSharp.tcpServer attribute = null, fastCSharp.code.cSharp.tcpBase.ITcpClientVerify verify = null) #endif { tcpCommandClient = new fastCSharp.net.tcp.commandClient <tcpClient>(attribute ?? fastCSharp.code.cSharp.tcpServer.GetConfig("loadBalancingTest", typeof(fastCSharp.demo.loadBalancingTcpCommand.server)), 28, verify); }
/// <summary> /// 时间验证客户端验证 /// </summary> /// <param name="client"></param> /// <param name="verifyMethod"></param> /// <returns></returns> public static bool Verify(fastCSharp.net.tcp.commandClient client, verifyMethod verifyMethod) { return(verify(client, verifyMethod));//tcpCallServer.attribute.VerifyString }