예제 #1
0
 private void sendButton_Click(object sender, EventArgs e)
 {
     if (inputTextBox.Text == "*CLOSE*")
     {
         mData.Close();
     }
     else if (inputTextBox.Text == "*PAUSE*")
     {
         mData.ParentConnection.Pause();
     }
     else if (inputTextBox.Text == "*RESUME*")
     {
         mData.ParentConnection.Resume();
     }
     else
     {
         mData.Send(inputTextBox.Text);
     }
     messageTextBox.Text += ("Local: " + inputTextBox.Text + "\r\n");
     inputTextBox.Text    = "";
 }
예제 #2
0
        void StartSendingJunk()
        {
            Task.Run((Action)(async() =>
            {
                int count = 0;
                byte[] buffer = new byte[4096];
                WebRTCDataChannel.SendStatus status;

                if (totalBytes == 0 || (DateTime.Now - startTime).TotalSeconds > 10)
                {
                    startTime = DateTime.Now;
                    totalBytes = 0;
                    NormalResentPackets = 0;
                }

                if (closing)
                {
                    return;
                }

                do
                {
                    r.NextBytes(buffer);
                    status = mDataChannel.Send(buffer);
                    count += buffer.Length;
                } while (status == WebRTCDataChannel.SendStatus.ALL_DATA_SENT);



                totalBytes += count;

                count = (int)(((double)totalBytes) / (DateTime.Now - startTime).TotalSeconds) / 1024;
                if (!closing)
                {
                    await this.ContextSwitchToMessagePumpAsync();
                    sendRateLabel.Text = "Send Rate: " + count.ToString() + " KBytes / second";
                }
            }));
        }