public override IWebProxy GetProxy() { var proxy = new SimpleProxy(proxyUri); if (Credentials != null) { proxy.Credentials = Credentials; } return(proxy); }
static async Task MainAsync(X509Certificate2 serverCertificate) { var tlsConfig = new EpoxyServerTlsConfig(serverCertificate); EpoxyTransport transport = new EpoxyTransportBuilder().SetServerTlsConfig(tlsConfig).Construct(); await StartServiceListenersAsync(transport); var connection = await transport.ConnectToAsync("epoxys://localhost"); var proxy = new SimpleProxy <EpoxyConnection>(connection); IMessage <SimpleResult> response = await proxy.SimpleMethodAsync(); PrintResponse(response); }
protected void btnSearchSM_Click(object sender, EventArgs e) { string searchBasicURL = "http://api.musescore.com/services/rest/score.xml?oauth_consumer_key=fRWBMQeNaqrBfnckEjfbkH4634jtidSy&text="; string searchTxt = TextBox1.Text; string searchURL = searchBasicURL + searchTxt; DataSet ds = new DataSet(); DataTable dt = new DataTable(); dt.Columns.Add(new DataColumn("custom_url", typeof(string))); dt.Columns.Add(new DataColumn("title", typeof(string))); string data = SimpleProxy.GetResponseContent(searchURL); StringReader sReader = new StringReader(data); XmlReader reader = XmlReader.Create(sReader); bool read_customurl = true; bool read_title = true; DataRow dr = dt.NewRow(); while (reader.Read()) { if (!reader.IsStartElement() && reader.Name.ToString() == "score") { dt.Rows.Add(dr); read_customurl = true; read_title = true; dr = dt.NewRow(); continue; } if (reader.IsStartElement()) { string eleName = reader.Name.ToString(); if (eleName == "custom_url" && read_customurl) { string curl = reader.ReadString(); read_customurl = false; dr["custom_url"] = curl; } if (eleName == "title" && read_title) { string title = reader.ReadString(); read_title = false; dr["title"] = title; } } } dlSearch2.DataSource = dt; dlSearch2.DataBind(); }
static async Task MainAsync(X509Certificate2 serverCertificate) { var tlsConfig = new EpoxyServerTlsConfig(serverCertificate); EpoxyTransport transport = new EpoxyTransportBuilder().SetServerTlsConfig(tlsConfig).Construct(); EpoxyListener listener = transport.MakeListener(serviceEndpoint); listener.AddService(new SimpleService()); await listener.StartAsync(); var connection = await transport.ConnectToAsync("epoxys://localhost"); var proxy = new SimpleProxy<EpoxyConnection>(connection); IMessage<SimpleResult> response = await proxy.SimpleMethodAsync(); PrintResponse(response); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { try { string URL = "http://www.fueleconomy.gov/ws/rest/fuelprices"; string xmlContentsAsString = string.Empty; // Consuming the helper functions of SimpleProxy class written by Prof. Richard Rasala to obtain the response xmlContentsAsString = SimpleProxy.GetResponseContent(URL); // Calling the helper function to process the response XML and display it in the front end ProcessFuelEconomyXML(xmlContentsAsString); } catch (Exception ex) { } } }
static void Main(string[] args) { var simpleProxy = new SimpleProxy("passwrd"); simpleProxy.DoWork(); }
public static void DoWork() { var simpleProxy = new SimpleProxy("password"); simpleProxy.DoWork(); }
public void MoveSimple(PTZDirection direction) { PTZProfile profile = GetProfile(); if (profile == null) { return; } if (typeof(PTZSpecV1) == profile.spec.GetType()) { PTZSpecV1 spec = (PTZSpecV1)profile.spec; string url; int waitTime; if (direction == PTZDirection.Up) { waitTime = spec.TiltRunTimeMs; url = spec.up; } else if (direction == PTZDirection.Down) { waitTime = spec.TiltRunTimeMs; url = spec.down; } else if (direction == PTZDirection.Left) { waitTime = spec.PanRunTimeMs; url = spec.left; } else if (direction == PTZDirection.Right) { waitTime = spec.PanRunTimeMs; url = spec.right; } else if (spec.EnableDiagonals) { if (direction == PTZDirection.UpLeft) { url = spec.upleft; } else if (direction == PTZDirection.DownLeft) { url = spec.downleft; } else if (direction == PTZDirection.UpRight) { url = spec.upright; } else if (direction == PTZDirection.DownRight) { url = spec.downright; } else { return; } waitTime = Math.Min(spec.PanRunTimeMs, spec.TiltRunTimeMs); } else { return; } SimpleProxy.GetData(urlBase + url, camSpec.ptz_username, camSpec.ptz_password); if (spec.SendStopCommandAfterPanTilt && !string.IsNullOrWhiteSpace(spec.stopPanTilt)) { Thread.Sleep(waitTime); SimpleProxy.GetData(urlBase + spec.stopPanTilt, camSpec.ptz_username, camSpec.ptz_password); } } }
private void Preset(int presetNum, bool save) { PTZProfile profile = GetProfile(); if (profile == null) { return; } if (typeof(PTZSpecV1) == profile.spec.GetType()) { PTZSpecV1 spec = (PTZSpecV1)profile.spec; string url = null; if (presetNum == 1) { url = save ? spec.save_preset_1 : spec.load_preset_1; } else if (presetNum == 2) { url = save ? spec.save_preset_2 : spec.load_preset_2; } else if (presetNum == 3) { url = save ? spec.save_preset_3 : spec.load_preset_3; } else if (presetNum == 4) { url = save ? spec.save_preset_4 : spec.load_preset_4; } else if (presetNum == 5) { url = save ? spec.save_preset_5 : spec.load_preset_5; } else if (presetNum == 6) { url = save ? spec.save_preset_6 : spec.load_preset_6; } else if (presetNum == 7) { url = save ? spec.save_preset_7 : spec.load_preset_7; } else if (presetNum == 8) { url = save ? spec.save_preset_8 : spec.load_preset_8; } if (!string.IsNullOrWhiteSpace(url)) { try { byte[] image = MJpegServer.cm.GetLatestImage(cam.cameraSpec.id); if (image.Length > 0) { Util.WriteImageThumbnailToFile(image, Globals.ThumbsDirectoryBase + cam.cameraSpec.id.ToLower() + presetNum + ".jpg"); } } catch (Exception ex) { Logger.Debug(ex); } SimpleProxy.GetData(urlBase + url, camSpec.ptz_username, camSpec.ptz_password); } } }
public void Zoom(ZoomDirection direction, ZoomAmount amount) { PTZProfile profile = GetProfile(); if (profile == null) { return; } if (typeof(PTZSpecV1) == profile.spec.GetType()) { PTZSpecV1 spec = (PTZSpecV1)profile.spec; string url = null; int waitTime = 0; if (direction == ZoomDirection.In) { if (amount == ZoomAmount.Short && !string.IsNullOrWhiteSpace(spec.zoomInShort)) { waitTime = spec.ZoomRunTimeShortMs; url = spec.zoomInShort; } else if (amount == ZoomAmount.Medium && !string.IsNullOrWhiteSpace(spec.zoomInMedium)) { waitTime = spec.ZoomRunTimeMediumMs; url = spec.zoomInMedium; } else if (amount == ZoomAmount.Long && !string.IsNullOrWhiteSpace(spec.zoomInLong)) { waitTime = spec.ZoomRunTimeLongMs; url = spec.zoomInLong; } } else if (direction == ZoomDirection.Out) { if (amount == ZoomAmount.Short && !string.IsNullOrWhiteSpace(spec.zoomOutShort)) { waitTime = spec.ZoomRunTimeShortMs; url = spec.zoomOutShort; } else if (amount == ZoomAmount.Medium && !string.IsNullOrWhiteSpace(spec.zoomOutMedium)) { waitTime = spec.ZoomRunTimeMediumMs; url = spec.zoomOutMedium; } else if (amount == ZoomAmount.Long && !string.IsNullOrWhiteSpace(spec.zoomOutLong)) { waitTime = spec.ZoomRunTimeLongMs; url = spec.zoomOutLong; } } if (string.IsNullOrWhiteSpace(url)) { return; } SimpleProxy.GetData(urlBase + url, camSpec.ptz_username, camSpec.ptz_password); if (spec.SendStopCommandAfterZoom && !string.IsNullOrWhiteSpace(spec.stopZoom)) { Thread.Sleep(waitTime); SimpleProxy.GetData(urlBase + spec.stopZoom, camSpec.ptz_username, camSpec.ptz_password); } } }
static void RunProxy() { SimpleProxy sp = new SimpleProxy("127.0.0.1:8888".Listen(), "127.0.0.1:5432"); sp.Start(); }