예제 #1
0
        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);
        }
예제 #2
0
 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);
 }
예제 #3
0
 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);
 }
예제 #4
0
        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);
        }
예제 #5
0
        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);
        }
예제 #6
0
        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);
        }
예제 #7
0
파일: MainForm.cs 프로젝트: PearLtd/iWebRTC
        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);
        }
예제 #8
0
 public WebRTCCommons.CustomAwaiter <string> GetOffer()
 {
     WebRTCCommons.CustomAwaiter <string> retVal = new WebRTCCommons.CustomAwaiter <string>();
     GetOfferAsync(retVal);
     return(retVal);
 }
예제 #9
0
        private async void GetOfferAsync(WebRTCCommons.CustomAwaiter <string> awaiter)
        {
            string sdp = await mConnection.GenerateOffer();

            awaiter.SetComplete(sdp);
        }
예제 #10
0
 public WebRTCCommons.CustomAwaiter <byte[]> GetOfferResponse(string offer)
 {
     WebRTCCommons.CustomAwaiter <byte[]> retVal = new WebRTCCommons.CustomAwaiter <byte[]>();
     GetOfferResponseAsync(retVal, offer);
     return(retVal);
 }
예제 #11
0
 public WebRTCCommons.CustomAwaiter<string> GetOffer()
 {
     WebRTCCommons.CustomAwaiter<string> retVal = new WebRTCCommons.CustomAwaiter<string>();
     GetOfferAsync(retVal);
     return (retVal);
 }
예제 #12
0
 public WebRTCCommons.CustomAwaiter<byte[]> GetOfferResponse(string offer)
 {
     WebRTCCommons.CustomAwaiter<byte[]> retVal = new WebRTCCommons.CustomAwaiter<byte[]>();
     GetOfferResponseAsync(retVal, offer);           
     return (retVal);
 }