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 } }
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); }
async void mConnection_DebugEvents_OnTSNFloorNotRaised(WebRTCConnection sender, int resendCounter) { tsncounter++; await this.ContextSwitchToMessagePumpAsync(); tsnLabel.Text = "(" + tsncounter.ToString() + ") Resend Count: " + resendCounter.ToString(); }
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(); } }
async void mConnection_DebugEvents_OnTSNFloorNotRaised(WebRTCConnection sender, int resendCounter) { tsncounter++; await this.ContextSwitchToMessagePumpAsync(); tsnLabel.Text = "(" + tsncounter.ToString() + ") Resend Count: " + resendCounter.ToString(); }
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]"); }
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"; }
async void mConnection_DebugEvents_OnReceiverCredits(WebRTCConnection sender, int receiverCredits) { if (receiverCredits < 0) { int x = 5; } await this.ContextSwitchToMessagePumpAsync(); rCreditsLabel.Text = "Receiver Credits: " + receiverCredits.ToString(); }
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(); } }
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]"); }
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; }
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(); } }
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); }
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(); }
void mConnection_OnDisconnected(WebRTCConnection sender) { mConnected = false; mConnection = null; if (!closing) { BeginInvoke((Action)(() => { Close(); })); } }
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(); }
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]"); }
async void mConnection_DebugEvents_OnCongestionWindowSizeChanged(WebRTCConnection sender, int windowSize) { await this.ContextSwitchToMessagePumpAsync(); this.windowSizeLabel.Text = "Congestion Window Size: " + windowSize.ToString() + " bytes"; }
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 } }
void mConnection_DebugEvents_OnHold(WebRTCConnection sender, int holdCount) { }
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; }
async void mConnection_DebugEvents_OnSACKReceived(WebRTCConnection sender, uint TSN) { await this.ContextSwitchToMessagePumpAsync(); rCreditsLabel.Text = "SACKs received: " + (++sackpackets).ToString(); }
void mConnection_DebugEvents_OnHold(WebRTCConnection sender, int holdCount) { }
async void mConnection_DebugEvents_OnRTTCalculated(WebRTCConnection sender, int SRTT) { await this.ContextSwitchToMessagePumpAsync(); rttLabel.Text = "Round Trip Time: " + SRTT.ToString() + "ms calculated @" + DateTime.Now.ToLongTimeString(); }
void mConnection_OnConnectionSendOk(WebRTCConnection sender) { StartSendingJunk(); }
public DebugForm(WebRTCConnection connection) { InitializeComponent(); Text = "WebRTC Debug View - NOT Connected"; mConnection = connection; }
public DebugForm(WebRTCConnection connection) { InitializeComponent(); Text = "WebRTC Debug View - NOT Connected"; mConnection = connection; }
async void mConnection_DebugEvents_OnRTTCalculated(WebRTCConnection sender, int SRTT) { await this.ContextSwitchToMessagePumpAsync(); rttLabel.Text = "Round Trip Time: " + SRTT.ToString() + "ms calculated @" + DateTime.Now.ToLongTimeString(); }
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"; }
async void mConnection_DebugEvents_OnSACKReceived(WebRTCConnection sender, uint TSN) { await this.ContextSwitchToMessagePumpAsync(); rCreditsLabel.Text = "SACKs received: " + (++sackpackets).ToString(); }
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]"); }
async void mConnection_DebugEvents_OnCongestionWindowSizeChanged(WebRTCConnection sender, int windowSize) { await this.ContextSwitchToMessagePumpAsync(); this.windowSizeLabel.Text = "Congestion Window Size: " + windowSize.ToString() + " bytes"; }
void mConnection_OnConnectionSendOk(WebRTCConnection sender) { StartSendingJunk(); }
async void mConnection_DebugEvents_OnReceiverCredits(WebRTCConnection sender, int receiverCredits) { if (receiverCredits < 0) { int x = 5; } await this.ContextSwitchToMessagePumpAsync(); rCreditsLabel.Text = "Receiver Credits: " + receiverCredits.ToString(); }