You've already forked lidgren-network-gen3
mirror of
https://github.com/lidgren/lidgren-network-gen3.git
synced 2026-05-14 06:06:30 +09:00
transferred from trunk/Generation3 of lidgren-network
This commit is contained in:
58
Samples/SamplesCommon/NativeMethods.cs
Normal file
58
Samples/SamplesCommon/NativeMethods.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace SamplesCommon
|
||||
{
|
||||
public static class NativeMethods
|
||||
{
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto)]
|
||||
public static extern int SendMessage(IntPtr hWnd, int wMsg, IntPtr wParam, IntPtr lParam);
|
||||
public const int WM_VSCROLL = 277; // Vertical scroll
|
||||
public const int SB_BOTTOM = 7; // Scroll to bottom
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct PeekMsg
|
||||
{
|
||||
public IntPtr hWnd;
|
||||
public Message msg;
|
||||
public IntPtr wParam;
|
||||
public IntPtr lParam;
|
||||
public uint time;
|
||||
public System.Drawing.Point p;
|
||||
}
|
||||
|
||||
[System.Security.SuppressUnmanagedCodeSecurity] // We won't use this maliciously
|
||||
[DllImport("User32.dll", CharSet = CharSet.Auto)]
|
||||
public static extern bool PeekMessage(out PeekMsg msg, IntPtr hWnd, uint messageFilterMin, uint messageFilterMax, uint flags);
|
||||
|
||||
public static bool AppStillIdle
|
||||
{
|
||||
get
|
||||
{
|
||||
PeekMsg msg;
|
||||
return !PeekMessage(out msg, IntPtr.Zero, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public static void AppendText(RichTextBox box, string line)
|
||||
{
|
||||
try
|
||||
{
|
||||
box.AppendText(line + Environment.NewLine);
|
||||
ScrollRichTextBox(box);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public static void ScrollRichTextBox(RichTextBox box)
|
||||
{
|
||||
if (box == null || box.IsDisposed || box.Disposing)
|
||||
return;
|
||||
SendMessage(box.Handle, WM_VSCROLL, (IntPtr)SB_BOTTOM, IntPtr.Zero);
|
||||
}
|
||||
}
|
||||
}
|
||||
362
Samples/SamplesCommon/NetPeerSettingsWindow.Designer.cs
generated
Normal file
362
Samples/SamplesCommon/NetPeerSettingsWindow.Designer.cs
generated
Normal file
@@ -0,0 +1,362 @@
|
||||
namespace SamplesCommon
|
||||
{
|
||||
partial class NetPeerSettingsWindow
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.DebugCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.VerboseCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||
this.label10 = new System.Windows.Forms.Label();
|
||||
this.label11 = new System.Windows.Forms.Label();
|
||||
this.ThrottleTextBox = new System.Windows.Forms.TextBox();
|
||||
this.label8 = new System.Windows.Forms.Label();
|
||||
this.label9 = new System.Windows.Forms.Label();
|
||||
this.textBox2 = new System.Windows.Forms.TextBox();
|
||||
this.label5 = new System.Windows.Forms.Label();
|
||||
this.label4 = new System.Windows.Forms.Label();
|
||||
this.textBox3 = new System.Windows.Forms.TextBox();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.LossTextBox = new System.Windows.Forms.TextBox();
|
||||
this.MinLatencyTextBox = new System.Windows.Forms.TextBox();
|
||||
this.groupBox2 = new System.Windows.Forms.GroupBox();
|
||||
this.label7 = new System.Windows.Forms.Label();
|
||||
this.label6 = new System.Windows.Forms.Label();
|
||||
this.textBox1 = new System.Windows.Forms.TextBox();
|
||||
this.button1 = new System.Windows.Forms.Button();
|
||||
this.groupBox3 = new System.Windows.Forms.GroupBox();
|
||||
this.StatisticsLabel = new System.Windows.Forms.Label();
|
||||
this.button2 = new System.Windows.Forms.Button();
|
||||
this.groupBox1.SuspendLayout();
|
||||
this.groupBox2.SuspendLayout();
|
||||
this.groupBox3.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// DebugCheckBox
|
||||
//
|
||||
this.DebugCheckBox.AutoSize = true;
|
||||
this.DebugCheckBox.Location = new System.Drawing.Point(6, 21);
|
||||
this.DebugCheckBox.Name = "DebugCheckBox";
|
||||
this.DebugCheckBox.Size = new System.Drawing.Size(153, 17);
|
||||
this.DebugCheckBox.TabIndex = 0;
|
||||
this.DebugCheckBox.Text = "Display Debug messages";
|
||||
this.DebugCheckBox.UseVisualStyleBackColor = true;
|
||||
this.DebugCheckBox.CheckedChanged += new System.EventHandler(this.DebugCheckBox_CheckedChanged);
|
||||
//
|
||||
// VerboseCheckBox
|
||||
//
|
||||
this.VerboseCheckBox.AutoSize = true;
|
||||
this.VerboseCheckBox.Location = new System.Drawing.Point(6, 44);
|
||||
this.VerboseCheckBox.Name = "VerboseCheckBox";
|
||||
this.VerboseCheckBox.Size = new System.Drawing.Size(197, 17);
|
||||
this.VerboseCheckBox.TabIndex = 1;
|
||||
this.VerboseCheckBox.Text = "Display Verbose debug messages";
|
||||
this.VerboseCheckBox.UseVisualStyleBackColor = true;
|
||||
this.VerboseCheckBox.CheckedChanged += new System.EventHandler(this.VerboseCheckBox_CheckedChanged);
|
||||
//
|
||||
// groupBox1
|
||||
//
|
||||
this.groupBox1.Controls.Add(this.label10);
|
||||
this.groupBox1.Controls.Add(this.label11);
|
||||
this.groupBox1.Controls.Add(this.ThrottleTextBox);
|
||||
this.groupBox1.Controls.Add(this.label8);
|
||||
this.groupBox1.Controls.Add(this.label9);
|
||||
this.groupBox1.Controls.Add(this.textBox2);
|
||||
this.groupBox1.Controls.Add(this.label5);
|
||||
this.groupBox1.Controls.Add(this.label4);
|
||||
this.groupBox1.Controls.Add(this.textBox3);
|
||||
this.groupBox1.Controls.Add(this.label3);
|
||||
this.groupBox1.Controls.Add(this.label2);
|
||||
this.groupBox1.Controls.Add(this.label1);
|
||||
this.groupBox1.Controls.Add(this.LossTextBox);
|
||||
this.groupBox1.Controls.Add(this.MinLatencyTextBox);
|
||||
this.groupBox1.Location = new System.Drawing.Point(291, 12);
|
||||
this.groupBox1.Name = "groupBox1";
|
||||
this.groupBox1.Size = new System.Drawing.Size(300, 142);
|
||||
this.groupBox1.TabIndex = 2;
|
||||
this.groupBox1.TabStop = false;
|
||||
this.groupBox1.Text = "Simulation";
|
||||
//
|
||||
// label10
|
||||
//
|
||||
this.label10.AutoSize = true;
|
||||
this.label10.Location = new System.Drawing.Point(163, 108);
|
||||
this.label10.Name = "label10";
|
||||
this.label10.Size = new System.Drawing.Size(75, 13);
|
||||
this.label10.TabIndex = 13;
|
||||
this.label10.Text = "bytes/second";
|
||||
//
|
||||
// label11
|
||||
//
|
||||
this.label11.AutoSize = true;
|
||||
this.label11.Location = new System.Drawing.Point(6, 108);
|
||||
this.label11.Name = "label11";
|
||||
this.label11.Size = new System.Drawing.Size(47, 13);
|
||||
this.label11.TabIndex = 12;
|
||||
this.label11.Text = "Throttle";
|
||||
//
|
||||
// ThrottleTextBox
|
||||
//
|
||||
this.ThrottleTextBox.Location = new System.Drawing.Point(103, 105);
|
||||
this.ThrottleTextBox.Name = "ThrottleTextBox";
|
||||
this.ThrottleTextBox.Size = new System.Drawing.Size(54, 22);
|
||||
this.ThrottleTextBox.TabIndex = 11;
|
||||
this.ThrottleTextBox.TextChanged += new System.EventHandler(this.ThrottleTextBox_TextChanged);
|
||||
//
|
||||
// label8
|
||||
//
|
||||
this.label8.AutoSize = true;
|
||||
this.label8.Location = new System.Drawing.Point(163, 80);
|
||||
this.label8.Name = "label8";
|
||||
this.label8.Size = new System.Drawing.Size(16, 13);
|
||||
this.label8.TabIndex = 10;
|
||||
this.label8.Text = "%";
|
||||
//
|
||||
// label9
|
||||
//
|
||||
this.label9.AutoSize = true;
|
||||
this.label9.Location = new System.Drawing.Point(6, 80);
|
||||
this.label9.Name = "label9";
|
||||
this.label9.Size = new System.Drawing.Size(61, 13);
|
||||
this.label9.TabIndex = 9;
|
||||
this.label9.Text = "Duplicates";
|
||||
//
|
||||
// textBox2
|
||||
//
|
||||
this.textBox2.Location = new System.Drawing.Point(103, 77);
|
||||
this.textBox2.Name = "textBox2";
|
||||
this.textBox2.Size = new System.Drawing.Size(54, 22);
|
||||
this.textBox2.TabIndex = 8;
|
||||
this.textBox2.TextChanged += new System.EventHandler(this.textBox2_TextChanged);
|
||||
//
|
||||
// label5
|
||||
//
|
||||
this.label5.AutoSize = true;
|
||||
this.label5.Location = new System.Drawing.Point(163, 52);
|
||||
this.label5.Name = "label5";
|
||||
this.label5.Size = new System.Drawing.Size(16, 13);
|
||||
this.label5.TabIndex = 7;
|
||||
this.label5.Text = "%";
|
||||
//
|
||||
// label4
|
||||
//
|
||||
this.label4.AutoSize = true;
|
||||
this.label4.Location = new System.Drawing.Point(247, 24);
|
||||
this.label4.Name = "label4";
|
||||
this.label4.Size = new System.Drawing.Size(21, 13);
|
||||
this.label4.TabIndex = 6;
|
||||
this.label4.Text = "ms";
|
||||
//
|
||||
// textBox3
|
||||
//
|
||||
this.textBox3.Location = new System.Drawing.Point(185, 21);
|
||||
this.textBox3.Name = "textBox3";
|
||||
this.textBox3.Size = new System.Drawing.Size(54, 22);
|
||||
this.textBox3.TabIndex = 5;
|
||||
this.textBox3.TextChanged += new System.EventHandler(this.textBox3_TextChanged);
|
||||
//
|
||||
// label3
|
||||
//
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Location = new System.Drawing.Point(163, 24);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(18, 13);
|
||||
this.label3.TabIndex = 4;
|
||||
this.label3.Text = "to";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(6, 52);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(29, 13);
|
||||
this.label2.TabIndex = 3;
|
||||
this.label2.Text = "Loss";
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(6, 24);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(91, 13);
|
||||
this.label1.TabIndex = 2;
|
||||
this.label1.Text = "One way latency";
|
||||
//
|
||||
// LossTextBox
|
||||
//
|
||||
this.LossTextBox.Location = new System.Drawing.Point(103, 49);
|
||||
this.LossTextBox.Name = "LossTextBox";
|
||||
this.LossTextBox.Size = new System.Drawing.Size(54, 22);
|
||||
this.LossTextBox.TabIndex = 1;
|
||||
this.LossTextBox.TextChanged += new System.EventHandler(this.LossTextBox_TextChanged);
|
||||
//
|
||||
// MinLatencyTextBox
|
||||
//
|
||||
this.MinLatencyTextBox.Location = new System.Drawing.Point(103, 21);
|
||||
this.MinLatencyTextBox.Name = "MinLatencyTextBox";
|
||||
this.MinLatencyTextBox.Size = new System.Drawing.Size(54, 22);
|
||||
this.MinLatencyTextBox.TabIndex = 0;
|
||||
this.MinLatencyTextBox.TextChanged += new System.EventHandler(this.MinLatencyTextBox_TextChanged);
|
||||
//
|
||||
// groupBox2
|
||||
//
|
||||
this.groupBox2.Controls.Add(this.label7);
|
||||
this.groupBox2.Controls.Add(this.DebugCheckBox);
|
||||
this.groupBox2.Controls.Add(this.VerboseCheckBox);
|
||||
this.groupBox2.Controls.Add(this.label6);
|
||||
this.groupBox2.Controls.Add(this.textBox1);
|
||||
this.groupBox2.Location = new System.Drawing.Point(12, 12);
|
||||
this.groupBox2.Name = "groupBox2";
|
||||
this.groupBox2.Size = new System.Drawing.Size(273, 142);
|
||||
this.groupBox2.TabIndex = 3;
|
||||
this.groupBox2.TabStop = false;
|
||||
this.groupBox2.Text = "Settings";
|
||||
//
|
||||
// label7
|
||||
//
|
||||
this.label7.AutoSize = true;
|
||||
this.label7.Location = new System.Drawing.Point(182, 70);
|
||||
this.label7.Name = "label7";
|
||||
this.label7.Size = new System.Drawing.Size(21, 13);
|
||||
this.label7.TabIndex = 10;
|
||||
this.label7.Text = "ms";
|
||||
//
|
||||
// label6
|
||||
//
|
||||
this.label6.AutoSize = true;
|
||||
this.label6.Location = new System.Drawing.Point(6, 70);
|
||||
this.label6.Name = "label6";
|
||||
this.label6.Size = new System.Drawing.Size(84, 13);
|
||||
this.label6.TabIndex = 9;
|
||||
this.label6.Text = "Ping frequency";
|
||||
//
|
||||
// textBox1
|
||||
//
|
||||
this.textBox1.Location = new System.Drawing.Point(98, 67);
|
||||
this.textBox1.Name = "textBox1";
|
||||
this.textBox1.Size = new System.Drawing.Size(76, 22);
|
||||
this.textBox1.TabIndex = 8;
|
||||
this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged);
|
||||
//
|
||||
// button1
|
||||
//
|
||||
this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.button1.Location = new System.Drawing.Point(494, 367);
|
||||
this.button1.Name = "button1";
|
||||
this.button1.Size = new System.Drawing.Size(101, 36);
|
||||
this.button1.TabIndex = 5;
|
||||
this.button1.Text = "Refresh";
|
||||
this.button1.UseVisualStyleBackColor = true;
|
||||
this.button1.Click += new System.EventHandler(this.button1_Click);
|
||||
//
|
||||
// groupBox3
|
||||
//
|
||||
this.groupBox3.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.groupBox3.Controls.Add(this.StatisticsLabel);
|
||||
this.groupBox3.Location = new System.Drawing.Point(12, 160);
|
||||
this.groupBox3.Name = "groupBox3";
|
||||
this.groupBox3.Size = new System.Drawing.Size(579, 197);
|
||||
this.groupBox3.TabIndex = 6;
|
||||
this.groupBox3.TabStop = false;
|
||||
this.groupBox3.Text = "Statistics";
|
||||
//
|
||||
// StatisticsLabel
|
||||
//
|
||||
this.StatisticsLabel.AutoSize = true;
|
||||
this.StatisticsLabel.Location = new System.Drawing.Point(6, 22);
|
||||
this.StatisticsLabel.Name = "StatisticsLabel";
|
||||
this.StatisticsLabel.Size = new System.Drawing.Size(79, 13);
|
||||
this.StatisticsLabel.TabIndex = 0;
|
||||
this.StatisticsLabel.Text = "StatisticsLabel";
|
||||
//
|
||||
// button2
|
||||
//
|
||||
this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.button2.Location = new System.Drawing.Point(389, 367);
|
||||
this.button2.Name = "button2";
|
||||
this.button2.Size = new System.Drawing.Size(99, 36);
|
||||
this.button2.TabIndex = 7;
|
||||
this.button2.Text = "Close";
|
||||
this.button2.UseVisualStyleBackColor = true;
|
||||
this.button2.Click += new System.EventHandler(this.button2_Click);
|
||||
//
|
||||
// NetPeerSettingsWindow
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(603, 411);
|
||||
this.Controls.Add(this.button2);
|
||||
this.Controls.Add(this.groupBox3);
|
||||
this.Controls.Add(this.button1);
|
||||
this.Controls.Add(this.groupBox2);
|
||||
this.Controls.Add(this.groupBox1);
|
||||
this.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.Name = "NetPeerSettingsWindow";
|
||||
this.Text = "NetPeerSettingsWindow1";
|
||||
this.groupBox1.ResumeLayout(false);
|
||||
this.groupBox1.PerformLayout();
|
||||
this.groupBox2.ResumeLayout(false);
|
||||
this.groupBox2.PerformLayout();
|
||||
this.groupBox3.ResumeLayout(false);
|
||||
this.groupBox3.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.GroupBox groupBox1;
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.GroupBox groupBox2;
|
||||
private System.Windows.Forms.Label label5;
|
||||
private System.Windows.Forms.Label label4;
|
||||
private System.Windows.Forms.Label label3;
|
||||
public System.Windows.Forms.CheckBox DebugCheckBox;
|
||||
public System.Windows.Forms.CheckBox VerboseCheckBox;
|
||||
public System.Windows.Forms.TextBox LossTextBox;
|
||||
public System.Windows.Forms.TextBox MinLatencyTextBox;
|
||||
public System.Windows.Forms.TextBox textBox3;
|
||||
private System.Windows.Forms.Button button1;
|
||||
private System.Windows.Forms.Label label7;
|
||||
private System.Windows.Forms.Label label6;
|
||||
private System.Windows.Forms.TextBox textBox1;
|
||||
private System.Windows.Forms.GroupBox groupBox3;
|
||||
public System.Windows.Forms.Label StatisticsLabel;
|
||||
private System.Windows.Forms.Button button2;
|
||||
private System.Windows.Forms.Label label8;
|
||||
private System.Windows.Forms.Label label9;
|
||||
public System.Windows.Forms.TextBox textBox2;
|
||||
private System.Windows.Forms.Label label10;
|
||||
private System.Windows.Forms.Label label11;
|
||||
public System.Windows.Forms.TextBox ThrottleTextBox;
|
||||
}
|
||||
}
|
||||
156
Samples/SamplesCommon/NetPeerSettingsWindow.cs
Normal file
156
Samples/SamplesCommon/NetPeerSettingsWindow.cs
Normal file
@@ -0,0 +1,156 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.Reflection;
|
||||
|
||||
using Lidgren.Network;
|
||||
|
||||
namespace SamplesCommon
|
||||
{
|
||||
public partial class NetPeerSettingsWindow : Form
|
||||
{
|
||||
public NetPeer Peer;
|
||||
public Timer timer;
|
||||
|
||||
public NetPeerSettingsWindow(string title, NetPeer peer)
|
||||
{
|
||||
Peer = peer;
|
||||
InitializeComponent();
|
||||
RefreshData();
|
||||
this.Text = title;
|
||||
|
||||
// auto refresh now and then
|
||||
timer = new Timer();
|
||||
timer.Interval = 250;
|
||||
timer.Tick += new EventHandler(timer_Tick);
|
||||
timer.Enabled = true;
|
||||
}
|
||||
|
||||
protected override void OnClosed(EventArgs e)
|
||||
{
|
||||
timer.Enabled = false;
|
||||
base.OnClosed(e);
|
||||
}
|
||||
|
||||
void timer_Tick(object sender, EventArgs e)
|
||||
{
|
||||
RefreshData();
|
||||
}
|
||||
|
||||
private void RefreshData()
|
||||
{
|
||||
#if DEBUG
|
||||
LossTextBox.Text = ((int)(Peer.Configuration.SimulatedLoss * 100)).ToString();
|
||||
textBox2.Text = ((int)(Peer.Configuration.SimulatedDuplicatesChance * 100)).ToString();
|
||||
MinLatencyTextBox.Text = ((int)(Peer.Configuration.SimulatedMinimumLatency * 1000)).ToString();
|
||||
textBox3.Text = ((int)((Peer.Configuration.SimulatedMinimumLatency + Peer.Configuration.SimulatedRandomLatency) * 1000)).ToString();
|
||||
#else
|
||||
LossTextBox.Text = "0";
|
||||
MinLatencyTextBox.Text = "0";
|
||||
textBox3.Text = "0";
|
||||
textBox2.Text = "0";
|
||||
#endif
|
||||
DebugCheckBox.Checked = Peer.Configuration.IsMessageTypeEnabled(NetIncomingMessageType.DebugMessage);
|
||||
VerboseCheckBox.Checked = Peer.Configuration.IsMessageTypeEnabled(NetIncomingMessageType.VerboseDebugMessage);
|
||||
textBox1.Text = (Peer.Configuration.PingFrequency * 1000).ToString();
|
||||
ThrottleTextBox.Text = Peer.Configuration.ThrottleBytesPerSecond.ToString();
|
||||
|
||||
StringBuilder bdr = new StringBuilder();
|
||||
bdr.AppendLine(Peer.Statistics.ToString());
|
||||
|
||||
if (Peer.ConnectionsCount > 0)
|
||||
{
|
||||
NetConnection conn = Peer.Connections[0];
|
||||
bdr.AppendLine("Connection 0:");
|
||||
bdr.AppendLine("Average RTT: " + ((int)(conn.AverageRoundtripTime * 1000.0f)) + " ms");
|
||||
bdr.Append(conn.Statistics.ToString());
|
||||
}
|
||||
|
||||
StatisticsLabel.Text = bdr.ToString();
|
||||
}
|
||||
|
||||
private void DebugCheckBox_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
Peer.Configuration.SetMessageTypeEnabled(NetIncomingMessageType.DebugMessage, DebugCheckBox.Checked);
|
||||
}
|
||||
|
||||
private void VerboseCheckBox_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
Peer.Configuration.SetMessageTypeEnabled(NetIncomingMessageType.VerboseDebugMessage, VerboseCheckBox.Checked);
|
||||
}
|
||||
|
||||
private void LossTextBox_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
#if DEBUG
|
||||
float ms;
|
||||
if (Single.TryParse(LossTextBox.Text, out ms))
|
||||
Peer.Configuration.SimulatedLoss = (float)((double)ms / 100.0);
|
||||
#endif
|
||||
}
|
||||
|
||||
private void textBox2_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
#if DEBUG
|
||||
float ms;
|
||||
if (Single.TryParse(textBox2.Text, out ms))
|
||||
Peer.Configuration.SimulatedDuplicatesChance = (float)((double)ms / 100.0);
|
||||
#endif
|
||||
}
|
||||
|
||||
private void MinLatencyTextBox_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
#if DEBUG
|
||||
float min;
|
||||
if (float.TryParse(MinLatencyTextBox.Text, out min))
|
||||
Peer.Configuration.SimulatedMinimumLatency = (float)(min / 1000.0);
|
||||
MinLatencyTextBox.Text = ((int)(Peer.Configuration.SimulatedMinimumLatency * 1000)).ToString();
|
||||
#endif
|
||||
}
|
||||
|
||||
private void textBox3_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
#if DEBUG
|
||||
float max;
|
||||
if (float.TryParse(textBox3.Text, out max))
|
||||
{
|
||||
max = (float)((double)max / 1000.0);
|
||||
float r = max - Peer.Configuration.SimulatedMinimumLatency;
|
||||
if (r > 0)
|
||||
{
|
||||
Peer.Configuration.SimulatedRandomLatency = r;
|
||||
double nm = (double)Peer.Configuration.SimulatedMinimumLatency + (double)Peer.Configuration.SimulatedRandomLatency;
|
||||
textBox3.Text = ((int)(max * 1000)).ToString();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
RefreshData();
|
||||
}
|
||||
|
||||
private void textBox1_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
float d;
|
||||
if (float.TryParse(textBox1.Text, out d))
|
||||
Peer.Configuration.PingFrequency = (float)(d / 1000.0);
|
||||
}
|
||||
|
||||
private void button2_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.Close();
|
||||
}
|
||||
|
||||
private void ThrottleTextBox_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
uint bps;
|
||||
if (UInt32.TryParse(ThrottleTextBox.Text, out bps))
|
||||
Peer.Configuration.ThrottleBytesPerSecond = (int)bps;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
120
Samples/SamplesCommon/NetPeerSettingsWindow.resx
Normal file
120
Samples/SamplesCommon/NetPeerSettingsWindow.resx
Normal file
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
36
Samples/SamplesCommon/Properties/AssemblyInfo.cs
Normal file
36
Samples/SamplesCommon/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("SamplesCommon")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Microsoft")]
|
||||
[assembly: AssemblyProduct("SamplesCommon")]
|
||||
[assembly: AssemblyCopyright("Copyright © Microsoft 2010")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("7d1622f4-1dc7-4e94-8ec0-0a2a295dcf9a")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
72
Samples/SamplesCommon/SamplesCommon.csproj
Normal file
72
Samples/SamplesCommon/SamplesCommon.csproj
Normal file
@@ -0,0 +1,72 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>9.0.21022</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{773069DA-B66E-4667-ADCB-0D215AD8CF3E}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>SamplesCommon</RootNamespace>
|
||||
<AssemblyName>SamplesCommon</AssemblyName>
|
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Data" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="NativeMethods.cs" />
|
||||
<Compile Include="NetPeerSettingsWindow.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="NetPeerSettingsWindow.Designer.cs">
|
||||
<DependentUpon>NetPeerSettingsWindow.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="NetPeerSettingsWindow.resx">
|
||||
<DependentUpon>NetPeerSettingsWindow.cs</DependentUpon>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Lidgren.Network\Lidgren.Network.csproj">
|
||||
<Project>{FA245447-5F23-4AA1-BD5F-8D2DDF33CFBD}</Project>
|
||||
<Name>Lidgren.Network</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
Reference in New Issue
Block a user