Пример #1
0
        async void mConnection_OnConnected(WebRTCConnection sender)
        {
            mConnected = true;
            await this.ContextSwitchToMessagePumpAsync(); // Switch to UI Thread so we can modify the UI

            messageTextBox.Text += ("Connected at " + DateTime.Now.ToShortTimeString() + "\r\n");
            messageTextBox.Select(messageTextBox.Text.Length, 0);

            WebRTCDataChannel dc = await sender.CreateDataChannel("MyDataChannel"); // Wait to see if this is ACK'ed

            if (dc != null)
            {
                // YUP
                mData = dc;
                mData.OnStringReceiveData += mData_OnStringReceiveData;
                mData.OnClosing           += mData_OnClosing;
            }

            await this.ContextSwitchToMessagePumpAsync(); // Switch to UI thread so we can modify the UI... (The last await may have switched us to the WebRTC thread)

            messageTextBox.Text += ("Local DataChannel Creation (MyDataChannel) was " + (dc != null ? "ACKed" : "NOT ACKed") + "\r\n");
            messageTextBox.Select(messageTextBox.Text.Length, 0);
            if (dc != null)
            {
                inputTextBox.Enabled = true; // Only setting if true, because there could already be a dataChannel that has already enabled the textbox
            }
        }
Пример #2
0
        async void mConnection_OnConnected(WebRTCConnection sender)
        {
            mConnected = true;
            BeginInvoke((Action)(() =>
            {
                messageTextBox.Text += ("Connected at " + DateTime.Now.ToShortTimeString() + "\r\n");
                messageTextBox.Select(messageTextBox.Text.Length, 0);
            }));

            WebRTCDataChannel dc = await sender.CreateDataChannel("MyDataChannel"); // Wait to see if this is ACK'ed

            if (dc != null)
            {
                // YUP
                mData = dc;
                mData.OnStringReceiveData += mData_OnStringReceiveData;
                mData.OnClosing           += mData_OnClosing;
            }

            BeginInvoke(((Action <WebRTCDataChannel>)((d) =>
            {
                messageTextBox.Text += ("Local DataChannel Creation (MyDataChannel) was " + (d != null ? "ACKed" : "NOT ACKed") + "\r\n");
                messageTextBox.Select(messageTextBox.Text.Length, 0);
                if (d != null)
                {
                    inputTextBox.Enabled = true;     // Only setting if true, because there could already be a dataChannel that has already enabled the textbox
                }
            })), dc);
        }
Пример #3
0
        async void mConnection_DebugEvents_OnTSNFloorNotRaised(WebRTCConnection sender, int resendCounter)
        {
            tsncounter++;
            await this.ContextSwitchToMessagePumpAsync();

            tsnLabel.Text = "(" + tsncounter.ToString() + ") Resend Count: " + resendCounter.ToString();
        }
Пример #4
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;
            int dport = WebRTCConnection.StartDefaultLogger(0);

            this.Text += " [dPort: " + dport.ToString() + "]";

            System.Diagnostics.Process.Start("http://127.0.0.1:" + dport.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();
            }
        }
Пример #5
0
        async void mConnection_DebugEvents_OnTSNFloorNotRaised(WebRTCConnection sender, int resendCounter)
        {
            tsncounter++;
            await this.ContextSwitchToMessagePumpAsync();

            tsnLabel.Text = "(" + tsncounter.ToString() + ") Resend Count: " + resendCounter.ToString();
        }
Пример #6
0
        async void mConnection_DebugEvents_OnT3RTX(WebRTCConnection sender, bool IsExpired, bool IsEnabled, int RTOValue)
        {
            await this.ContextSwitchToMessagePumpAsync();
            if (IsExpired) { t3Label.ForeColor = Color.DarkRed; ++t3rtxcounter; }
            if (!IsExpired && !IsEnabled) t3Label.ForeColor = Color.Black;
            if (IsEnabled) t3Label.ForeColor = Color.DarkGreen;

            t3Label.Text = "T3-RTX Timer [" + t3rtxcounter.ToString() + "]: " + (IsEnabled ? ("[ENABLED] " + RTOValue.ToString() + " ms") : "[DISABLED]");
        }
Пример #7
0
        async void mConnection_DebugEvents_OnSendFastRetry(WebRTCConnection sender, int retryCount)
        {
            FastResentPackets += retryCount;
            int rate = (int)(((double)FastResentPackets) / (DateTime.Now - FastEnterTime).TotalSeconds) / 1024;

            await this.ContextSwitchToMessagePumpAsync();

            retryLabel.Text = "Fast Retry Rate: " + rate.ToString() + " KB/second";
        }
Пример #8
0
        async void mConnection_DebugEvents_OnReceiverCredits(WebRTCConnection sender, int receiverCredits)
        {
            if (receiverCredits < 0)
            {
                int x = 5;
            }
            await this.ContextSwitchToMessagePumpAsync();

            rCreditsLabel.Text = "Receiver Credits: " + receiverCredits.ToString();
        }
Пример #9
0
 async void mConnection_OnDisconnected(WebRTCConnection sender)
 {
     mConnected = false;
     mConnection = null;
     if (!closing)
     {
         await this.ContextSwitchToMessagePumpAsync(); // Switch to UI Thread so we can modify the UI
         Close();
     }
 }
Пример #10
0
        async void mConnection_DebugEvents_OnFastRecovery(WebRTCConnection sender, bool EnterFastRecovery)
        {
            if (EnterFastRecovery)
            {
                FastEnterTime = DateTime.Now; FastResentPackets = 0;
            }
            await this.ContextSwitchToMessagePumpAsync();

            retryLabel.ForeColor   = EnterFastRecovery ? Color.DarkGreen : Color.DarkRed;
            fastRecoveryLabel.Text = "Fast Recovery Mode: " + (EnterFastRecovery ? "[ENTERED]" : "[EXITED]");
        }
Пример #11
0
        async void mConnection_OnDataChannel(WebRTCConnection sender, WebRTCDataChannel DataChannel)
        {
            mData = DataChannel;
            mData.OnStringReceiveData += mData_OnStringReceiveData;

            await this.ContextSwitchToMessagePumpAsync(); // Switch to UI Thread so we can modify the UI

            messageTextBox.Text += ("DataChannel Created by Remote peer: (" + DataChannel.ChannelName + ") was established\r\n");
            messageTextBox.Select(messageTextBox.Text.Length, 0);
            inputTextBox.Enabled = true;
        }
Пример #12
0
        async void mConnection_OnDisconnected(WebRTCConnection sender)
        {
            mConnected  = false;
            mConnection = null;
            if (!closing)
            {
                await this.ContextSwitchToMessagePumpAsync(); // Switch to UI Thread so we can modify the UI

                Close();
            }
        }
Пример #13
0
        void mConnection_OnDataChannel(WebRTCConnection sender, WebRTCDataChannel DataChannel)
        {
            mData = DataChannel;
            mData.OnStringReceiveData += mData_OnStringReceiveData;

            BeginInvoke(((Action <WebRTCDataChannel>)((dc) =>
            {
                messageTextBox.Text += ("DataChannel Created by Remote peer: (" + dc.ChannelName + "[" + dc.StreamId.ToString() + "]) was established\r\n");
                messageTextBox.Select(messageTextBox.Text.Length, 0);
                inputTextBox.Enabled = true;
            })), DataChannel);
        }
Пример #14
0
        public SessionForm()
        {
            InitializeComponent();

            mConnection = new WebRTCConnection();

            mConnection.OnConnected    += mConnection_OnConnected;
            mConnection.OnDisconnected += mConnection_OnDisconnected;
            mConnection.OnDataChannel  += mConnection_OnDataChannel;
            messageTextBox.Text        += ("Got offer at " + DateTime.Now.ToShortTimeString() + ", buiding answer...\r\n");
            this.Text += " dPort: " + WebRTCConnection.StartDefaultLogger(0).ToString();
        }
Пример #15
0
 void mConnection_OnDisconnected(WebRTCConnection sender)
 {
     mConnected  = false;
     mConnection = null;
     if (!closing)
     {
         BeginInvoke((Action)(() =>
         {
             Close();
         }));
     }
 }
Пример #16
0
        public SessionForm()
        {
            InitializeComponent();

            mConnection = new WebRTCConnection();

            mConnection.OnConnected += mConnection_OnConnected;
            mConnection.OnDisconnected += mConnection_OnDisconnected;
            mConnection.OnDataChannel += mConnection_OnDataChannel;
            messageTextBox.Text += ("Got offer at " + DateTime.Now.ToShortTimeString() + ", buiding answer...\r\n");
            this.Text += " dPort: " + WebRTCConnection.StartDefaultLogger(0).ToString();
        }
Пример #17
0
        async void mConnection_DebugEvents_OnT3RTX(WebRTCConnection sender, bool IsExpired, bool IsEnabled, int RTOValue)
        {
            await this.ContextSwitchToMessagePumpAsync();

            if (IsExpired)
            {
                t3Label.ForeColor = Color.DarkRed; ++t3rtxcounter;
            }
            if (!IsExpired && !IsEnabled)
            {
                t3Label.ForeColor = Color.Black;
            }
            if (IsEnabled)
            {
                t3Label.ForeColor = Color.DarkGreen;
            }

            t3Label.Text = "T3-RTX Timer [" + t3rtxcounter.ToString() + "]: " + (IsEnabled ? ("[ENABLED] " + RTOValue.ToString() + " ms") : "[DISABLED]");
        }
Пример #18
0
        async void mConnection_DebugEvents_OnCongestionWindowSizeChanged(WebRTCConnection sender, int windowSize)
        {
            await this.ContextSwitchToMessagePumpAsync();

            this.windowSizeLabel.Text = "Congestion Window Size: " + windowSize.ToString() + " bytes";
        }
Пример #19
0
        async void mConnection_OnConnected(WebRTCConnection sender)
        {
            mConnected = true;
            await this.ContextSwitchToMessagePumpAsync(); // Switch to UI Thread so we can modify the UI
            messageTextBox.Text += ("Connected at " + DateTime.Now.ToShortTimeString() + "\r\n");
            messageTextBox.Select(messageTextBox.Text.Length, 0);
            
            WebRTCDataChannel dc = await sender.CreateDataChannel("MyDataChannel"); // Wait to see if this is ACK'ed
            if (dc != null) 
            {
                // YUP
                mData = dc;
                mData.OnStringReceiveData += mData_OnStringReceiveData;
                mData.OnClosing += mData_OnClosing;
            }

            await this.ContextSwitchToMessagePumpAsync(); // Switch to UI thread so we can modify the UI... (The last await may have switched us to the WebRTC thread)
            messageTextBox.Text += ("Local DataChannel Creation (MyDataChannel) was " + (dc!=null ? "ACKed" : "NOT ACKed") + "\r\n");
            messageTextBox.Select(messageTextBox.Text.Length, 0);
            if (dc!=null)
            {
                inputTextBox.Enabled = true; // Only setting if true, because there could already be a dataChannel that has already enabled the textbox
            }         
        }
Пример #20
0
 void mConnection_DebugEvents_OnHold(WebRTCConnection sender, int holdCount)
 {
 }
Пример #21
0
        async void mConnection_OnDataChannel(WebRTCConnection sender, WebRTCDataChannel DataChannel)
        {
            mData = DataChannel;
            mData.OnStringReceiveData += mData_OnStringReceiveData;

            await this.ContextSwitchToMessagePumpAsync(); // Switch to UI Thread so we can modify the UI
            messageTextBox.Text += ("DataChannel Created by Remote peer: (" + DataChannel.ChannelName + ") was established\r\n");
            messageTextBox.Select(messageTextBox.Text.Length, 0);
            inputTextBox.Enabled = true;
        }
Пример #22
0
 async void mConnection_DebugEvents_OnSACKReceived(WebRTCConnection sender, uint TSN)
 {
     await this.ContextSwitchToMessagePumpAsync();
     rCreditsLabel.Text = "SACKs received: " + (++sackpackets).ToString();
 }
Пример #23
0
 void mConnection_DebugEvents_OnHold(WebRTCConnection sender, int holdCount)
 {
 }
Пример #24
0
 async void mConnection_DebugEvents_OnRTTCalculated(WebRTCConnection sender, int SRTT)
 {
     await this.ContextSwitchToMessagePumpAsync();
     rttLabel.Text = "Round Trip Time: " + SRTT.ToString() + "ms calculated @" + DateTime.Now.ToLongTimeString();
 }
Пример #25
0
 void mConnection_OnConnectionSendOk(WebRTCConnection sender)
 {
     StartSendingJunk();
 }
Пример #26
0
 public DebugForm(WebRTCConnection connection)
 {
     InitializeComponent();
     Text        = "WebRTC Debug View  -  NOT Connected";
     mConnection = connection;
 }
Пример #27
0
 public DebugForm(WebRTCConnection connection)
 {
     InitializeComponent();
     Text = "WebRTC Debug View  -  NOT Connected";
     mConnection = connection;            
 }
Пример #28
0
        async void mConnection_DebugEvents_OnRTTCalculated(WebRTCConnection sender, int SRTT)
        {
            await this.ContextSwitchToMessagePumpAsync();

            rttLabel.Text = "Round Trip Time: " + SRTT.ToString() + "ms calculated @" + DateTime.Now.ToLongTimeString();
        }
Пример #29
0
        async void mConnection_DebugEvents_OnSendFastRetry(WebRTCConnection sender, int retryCount)
        {
            FastResentPackets += retryCount;
            int rate = (int)(((double)FastResentPackets) / (DateTime.Now - FastEnterTime).TotalSeconds) / 1024;

            await this.ContextSwitchToMessagePumpAsync();
            retryLabel.Text = "Fast Retry Rate: " + rate.ToString() + " KB/second"; 
        }
Пример #30
0
        async void mConnection_DebugEvents_OnSACKReceived(WebRTCConnection sender, uint TSN)
        {
            await this.ContextSwitchToMessagePumpAsync();

            rCreditsLabel.Text = "SACKs received: " + (++sackpackets).ToString();
        }
Пример #31
0
 async void mConnection_DebugEvents_OnFastRecovery(WebRTCConnection sender, bool EnterFastRecovery)
 {
     if (EnterFastRecovery) { FastEnterTime = DateTime.Now; FastResentPackets = 0; }
     await this.ContextSwitchToMessagePumpAsync();
     retryLabel.ForeColor = EnterFastRecovery ? Color.DarkGreen : Color.DarkRed;
     fastRecoveryLabel.Text = "Fast Recovery Mode: " + (EnterFastRecovery ? "[ENTERED]" : "[EXITED]");
 }
Пример #32
0
 async void mConnection_DebugEvents_OnCongestionWindowSizeChanged(WebRTCConnection sender, int windowSize)
 {
     await this.ContextSwitchToMessagePumpAsync();
     this.windowSizeLabel.Text = "Congestion Window Size: " + windowSize.ToString() + " bytes";
 }
Пример #33
0
 void mConnection_OnConnectionSendOk(WebRTCConnection sender)
 {
     StartSendingJunk();
 }
Пример #34
0
 async void mConnection_DebugEvents_OnReceiverCredits(WebRTCConnection sender, int receiverCredits)
 {
     if (receiverCredits < 0)
     {
         int x = 5;
     }
     await this.ContextSwitchToMessagePumpAsync();
     rCreditsLabel.Text = "Receiver Credits: " + receiverCredits.ToString(); 
 }