/// <summary> /// 连接 /// </summary> /// <returns></returns> public async Task ConnectAsync() { var client = new EasyClient <IJTTPackageInfo>(Filter); client.PackageHandler += PackageHandler; client.Closed += Closed; EasyClient = client.AsClient(); try { var connected = await EasyClient.ConnectAsync( new IPEndPoint( IPAddress.Parse(Config.ServerHost), Config.ServerPort), CancellationToken.None); if (connected) { Logger.Log( NLog.LogLevel.Trace, LogType.系统跟踪, $"已连接服务器, " + $"\r\t\nServer: {Config.ServerHost}:{Config.ServerPort}."); StartReceive(); } else { Logger.Log( NLog.LogLevel.Trace, LogType.系统跟踪, $"连接服务器失败, " + $"\r\t\nServer: {Config.ServerHost}:{Config.ServerPort}."); } } catch (Exception ex) { Logger.Log( NLog.LogLevel.Error, LogType.系统异常, $"连接服务器时发生错误, " + $"\r\t\nServer: {Config.ServerHost}:{Config.ServerPort}.", null, ex); } }