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
}
}