/// <summary> /// 请求保存 /// </summary> /// <returns></returns> public override bool Save() { var nc = NetworkConfiguration.Current; if (nc.ProxyType != 3 || nc.ProxyClass == ProxyType.Http) { PolipoSocks5ToHttpProxyWrapper.Instance.Stop(); } else { var errMsg = ""; using (var dlg = new YetAnotherWaitingDialog { Title = "正在尝试启动Socks5代理..." }) { dlg.WorkCallbackAdvanced = _ => { var pw = PolipoSocks5ToHttpProxyWrapper.Instance; pw.Stop().Wait(); pw.ParentSocksServerAddress = nc.Socks5ServerAddr; pw.ParentSocksServerPort = nc.Socks5ServerPort; pw.Start().Wait(); if (!pw.IsRunning) { throw new Exception("无法启动应用。"); } NetClientHandler.RefreshWebProxy(); _.Title = "正在测试代理是否正确..."; var client = new NetClient(); client.Setting.Timeout = 30000; var str = client.Create <string>(HttpMethod.Get, "https://kyfw.12306.cn/otn/", null).Send(); if (!str.IsValid() || str.Result.IndexOf("铁路客户服务中心", StringComparison.Ordinal) == -1) { pw.Stop().Wait(); throw new Exception("无法通过指定的Socks5代理服务器访问12306。"); } }; dlg.ShowDialog(FindForm()); errMsg = dlg.Exception?.Message ?? ""; } if (!PolipoSocks5ToHttpProxyWrapper.Instance.IsRunning || !errMsg.IsNullOrEmpty()) { this.Error("未能成功启动Socks5代理服务器!错误:" + errMsg); return(false); } } NetClientHandler.RefreshWebProxy(); return(base.Save()); }
public EntityClientPlayerMP(Minecraft par1Minecraft, World par2World, Session par3Session, NetClientHandler par4NetClientHandler) : base(par1Minecraft, par2World, par3Session, 0) { InventoryUpdateTickCounter = 0; WasOnGround = false; ShouldStopSneaking = false; WasSneaking = false; TimeSinceMoved = 0; HasSetHealth = false; SendQueue = par4NetClientHandler; }
public PixelsClient() { _handler = new NetClientHandler(); _handler.ConnectionFailed += InvokeConnectionFailed; _handler.ConnectionSucceeded += InvokeConnectionSucceeded; _handler.MessageReceived += InvokeMessageReceived; _handler.Disconnected += InvokeDisconnected; _handler.ConnectionClosed += InvokeConnectionClosed; _handler.ConnectionRefused += InvokeConnectionRefused; }
public GuiDownloadTerrain(NetClientHandler par1NetClientHandler) { UpdateCounter = 0; NetHandler = par1NetClientHandler; }