private async void GetOfferResponseAsync(WebRTCCommons.CustomAwaiter <byte[]> awaiter, string offer) { string offerResponse = await mConnection.SetOffer(offer); byte[] r = UTF8Encoding.UTF8.GetBytes("HTTP/1.1 200 OK\r\nContent-Type: text/sdp\r\nConnection: close\r\nContent-Length: " + offerResponse.Length.ToString() + "\r\n\r\n" + offerResponse); awaiter.SetComplete(r); }
public static WebRTCCommons.CustomAwaiter<bool> ContextSwitchToMessagePumpAsync(this System.Windows.Forms.Form f) { WebRTCCommons.CustomAwaiter<bool> retVal = new WebRTCCommons.CustomAwaiter<bool>(); retVal.forceWait(); try { f.BeginInvoke((Action<WebRTCCommons.CustomAwaiter<bool>>)((a) => { a.SetComplete(true); }), retVal); } catch { } return (retVal); }
public static WebRTCCommons.CustomAwaiter <bool> ContextSwitchToMessagePumpAsync(this System.Windows.Forms.Form f) { WebRTCCommons.CustomAwaiter <bool> retVal = new WebRTCCommons.CustomAwaiter <bool>(); retVal.forceWait(); try { f.BeginInvoke((Action <WebRTCCommons.CustomAwaiter <bool> >)((a) => { a.SetComplete(true); }), retVal); } catch { } return(retVal); }
private void GetNewPOC(IPEndPoint from, WebRTCCommons.CustomAwaiter <byte[]> awaiter) { BeginInvoke((Action <IPEndPoint, WebRTCCommons.CustomAwaiter <byte[]> >)((origin, a) => { SessionForm f = new SessionForm(); if (StunServersInUse) { f.SetStunServers(false, StunServers); } f.FormClosing += SessionFormClosing; f.Show(this); userForms.Add("/" + f.Value.ToString(), f); string content = htmlpage.Replace("/*{{{ICESERVERS}}}*/", "").Replace("{{{OFFER_URL}}}", origin.Address.ToString() + ":" + mServer.Port.ToString() + "/" + f.Value.ToString()); string header = "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nConnection: close\r\nContent-Length: " + content.Length.ToString() + "\r\n\r\n"; a.SetComplete(UTF8Encoding.UTF8.GetBytes(header + content)); }), from, awaiter); }
private WebRTCCommons.CustomAwaiter <byte[]> OnGet(SimpleRendezvousServer sender, IPEndPoint from, string path) { WebRTCCommons.CustomAwaiter <byte[]> retVal = new WebRTCCommons.CustomAwaiter <byte[]>(); switch (path) { case "/start": GetNewPOC(from, retVal); break; case "/passive": GetNewPassivePOC(retVal); break; default: retVal.SetComplete(UTF8Encoding.UTF8.GetBytes("HTTP/1.1 404 Not Found\r\nConnection: close\r\n\r\n")); break; } return(retVal); }
private void GetNewPassivePOC(WebRTCCommons.CustomAwaiter <byte[]> awaiter) { BeginInvoke((Action <WebRTCCommons.CustomAwaiter <byte[]> >)(async(a) => { SessionForm f = new SessionForm(); if (StunServersInUse) { f.SetStunServers(false, StunServers); } f.FormClosing += SessionFormClosing; f.Show(this); userForms.Add("/" + f.Value.ToString(), f); string content = passiveHtmlpage.Replace("/*{{{ICESERVERS}}}*/", "").Replace("{{{OFFER_URL}}}", "127.0.0.1:" + mServer.Port.ToString() + "/" + f.Value.ToString()); string sdp = await f.GetOffer(); content = content.Replace("/*{{{SDP}}}*/", System.Convert.ToBase64String(UTF8Encoding.UTF8.GetBytes(sdp))); string header = "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nConnection: close\r\nContent-Length: " + content.Length.ToString() + "\r\n\r\n"; a.SetComplete(UTF8Encoding.UTF8.GetBytes(header + content)); }), awaiter); }
private WebRTCCommons.CustomAwaiter<byte[]> OnGet(SimpleRendezvousServer sender, IPEndPoint from, string path) { WebRTCCommons.CustomAwaiter<byte[]> retVal = new WebRTCCommons.CustomAwaiter<byte[]>(); switch (path) { case "/start": GetNewPOC(from, retVal); break; case "/passive": GetNewPassivePOC(retVal); break; default: retVal.SetComplete(UTF8Encoding.UTF8.GetBytes("HTTP/1.1 404 Not Found\r\nConnection: close\r\n\r\n")); break; } return (retVal); }
public WebRTCCommons.CustomAwaiter <string> GetOffer() { WebRTCCommons.CustomAwaiter <string> retVal = new WebRTCCommons.CustomAwaiter <string>(); GetOfferAsync(retVal); return(retVal); }
private async void GetOfferAsync(WebRTCCommons.CustomAwaiter <string> awaiter) { string sdp = await mConnection.GenerateOffer(); awaiter.SetComplete(sdp); }
public WebRTCCommons.CustomAwaiter <byte[]> GetOfferResponse(string offer) { WebRTCCommons.CustomAwaiter <byte[]> retVal = new WebRTCCommons.CustomAwaiter <byte[]>(); GetOfferResponseAsync(retVal, offer); return(retVal); }
public WebRTCCommons.CustomAwaiter<string> GetOffer() { WebRTCCommons.CustomAwaiter<string> retVal = new WebRTCCommons.CustomAwaiter<string>(); GetOfferAsync(retVal); return (retVal); }
public WebRTCCommons.CustomAwaiter<byte[]> GetOfferResponse(string offer) { WebRTCCommons.CustomAwaiter<byte[]> retVal = new WebRTCCommons.CustomAwaiter<byte[]>(); GetOfferResponseAsync(retVal, offer); return (retVal); }