Very simple HTTP/WebRTC rendez-vous server. It grabs a random local port and acts like a very basic HTTP server. It serves the WebRTC sample web page and handles offer/answer requests.
Ejemplo n.º 1
0
 public MainForm(string[] args)
 {
     InitializeComponent();
     try
     {
         htmlpage = File.ReadAllText("webrtcsample.html");
         passiveHtmlpage = File.ReadAllText("webrtcpassivesample.html");
         mServer = new SimpleRendezvousServer();
         mServer.OnGet = OnGet;
         mServer.OnPost = OnPost;
         serverStatusLabel.Text = "Running";
         serverLinkLabel.Text = "http://127.0.0.1:" + mServer.Port.ToString() + "/start";
         serverLinkLabel_passive.Text = "http://127.0.0.1:" + mServer.Port.ToString() + "/passive";
     }
     catch (Exception) { serverStatusLabel.Text = "Error"; }
     
     //WebRTCConnection.ChainAlwaysRunning = true;
     //this.Text += " [dPort: " + WebRTCConnection.StartDefaultLogger(0).ToString() + "]";
     
     if(args.Length == 1)
     {
         mPipe = new System.IO.Pipes.NamedPipeClientStream(".", args[0], System.IO.Pipes.PipeDirection.InOut);
         ((System.IO.Pipes.NamedPipeClientStream)mPipe).Connect();
         pipeBuffer = new byte[4096];
         StartClient();
     }
 }
Ejemplo n.º 2
0
        public MainForm(string[] args)
        {
            InitializeComponent();
            try
            {
                htmlpage                     = File.ReadAllText("webrtcsample.html");
                passiveHtmlpage              = File.ReadAllText("webrtcpassivesample.html");
                mServer                      = new SimpleRendezvousServer();
                mServer.OnGet                = OnGet;
                mServer.OnPost               = OnPost;
                serverStatusLabel.Text       = "Running";
                serverLinkLabel.Text         = "http://127.0.0.1:" + mServer.Port.ToString() + "/start";
                serverLinkLabel_passive.Text = "http://127.0.0.1:" + mServer.Port.ToString() + "/passive";
            }
            catch (Exception) { serverStatusLabel.Text = "Error"; }

            //WebRTCConnection.ChainAlwaysRunning = true;
            //this.Text += " [dPort: " + WebRTCConnection.StartDefaultLogger(0).ToString() + "]";

            if (args.Length == 1)
            {
                mPipe = new System.IO.Pipes.NamedPipeClientStream(".", args[0], System.IO.Pipes.PipeDirection.InOut);
                ((System.IO.Pipes.NamedPipeClientStream)mPipe).Connect();
                pipeBuffer = new byte[4096];
                StartClient();
            }
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
0
 private WebRTCCommons.CustomAwaiter<byte[]> OnPost(SimpleRendezvousServer sender, string path, string body)
 {
     return (userForms[path].GetOfferResponse(body));
 }
Ejemplo n.º 6
0
 private WebRTCCommons.CustomAwaiter <byte[]> OnPost(SimpleRendezvousServer sender, string path, string body)
 {
     return(userForms[path].GetOfferResponse(body));
 }