/// <summary> /// 执行测试 /// </summary> public override void ExecuteTest() { //测试时间 int testTimeSecs = 60; SocketClient client = new SocketClient() { CP_HeartBeatTime = 5, CP_ReSendTimes = 5, CP_RestartTime = 5, CP_ConnectTime = 5, CP_IsAutoReConnect = true }; client.CE_ReceiveMessage += Client_ReceiveMessage; client.CF_InitClient("127.0.0.1", 9696); client.CF_StartConnection(); PrintLogLn(MsgType.Info, $"等待连接服务器!"); Thread.Sleep(2000); PrintLogLn(MsgType.Info, $"测试时间{testTimeSecs}秒!"); while (testTimeSecs-- > 0) { if (client.CP_IsConnected) { client.CF_SendMessage("Send To Server"); } else { PrintLogLn(MsgType.Error, $"未连接到服务端!"); } Thread.Sleep(1000); } client.CF_StopConnection(); Thread.Sleep(2000); }