/// <summary> /// 状态更改事件 /// </summary> /// <param name="args"></param> private void TestClientClientOnStateChange(ConnectServerEventArgs args) { ConsoleHelper.TestClientWriteLine(args.Message); switch (args.State) { case ClientStateEnum.NotConfigured: break; case ClientStateEnum.Ready: break; case ClientStateEnum.Runing: var result = new DataResult { ResultType = MResultType.Success, Message = "Test" }; _testClientClient.SendCommandAsync(new Command("TestCommandHandler") { StringData = result.MToJson(), Message = "qwer" }); _testClientClient.StartListeningEventAsync().Wait(); break; case ClientStateEnum.ConnectionFailed: if (IsAutoReload) { ConsoleHelper.TestClientWriteLine("重新连接"); _testClientClient.ReloadAsync().Wait(); _testClientClient.StartListeningEventAsync().Wait(); } break; case ClientStateEnum.Stop: break; default: throw new ArgumentOutOfRangeException(); } }