diff --git a/Samples/LibraryTestSamples/ManySample/ManyClients/Client.Designer.cs b/Samples/LibraryTestSamples/ManySample/ManyClients/Client.Designer.cs new file mode 100644 index 0000000..099869d --- /dev/null +++ b/Samples/LibraryTestSamples/ManySample/ManyClients/Client.Designer.cs @@ -0,0 +1,61 @@ +namespace ManyClients +{ + partial class Client + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.button1 = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // button1 + // + this.button1.Location = new System.Drawing.Point(82, 21); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(106, 23); + this.button1.TabIndex = 0; + this.button1.Text = "Send message"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // Client + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(264, 69); + this.Controls.Add(this.button1); + this.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.Name = "Client"; + this.Text = "Client"; + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Button button1; + } +} \ No newline at end of file diff --git a/Samples/LibraryTestSamples/ManySample/ManyClients/Client.cs b/Samples/LibraryTestSamples/ManySample/ManyClients/Client.cs new file mode 100644 index 0000000..878d995 --- /dev/null +++ b/Samples/LibraryTestSamples/ManySample/ManyClients/Client.cs @@ -0,0 +1,88 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using Lidgren.Network; + +namespace ManyClients +{ + public partial class Client : Form + { + private const double c_sendFrequency = 1.0; + + public NetClient Net; + + private double m_lastSent; + + public Client() + { + InitializeComponent(); + + NetPeerConfiguration config = new NetPeerConfiguration("many"); +#if DEBUG + config.SimulatedLoss = 0.02f; +#endif + Net = new NetClient(config); + Net.Start(); + Net.Connect("localhost", 14242); + } + + protected override void OnClosed(EventArgs e) + { + Net.Shutdown("closed"); + } + + internal void Shutdown() + { + Net.Shutdown("bye"); + } + + internal void Heartbeat() + { + NetIncomingMessage inc; + while ((inc = Net.ReadMessage()) != null) + { + switch (inc.MessageType) + { + case NetIncomingMessageType.StatusChanged: + NetConnectionStatus status = (NetConnectionStatus)inc.ReadByte(); + this.Text = status.ToString(); + break; + case NetIncomingMessageType.ErrorMessage: + this.Text = inc.ReadString(); + break; + } + } + + // send message? + if (NetTime.Now > m_lastSent + c_sendFrequency) + { + var om = Net.CreateMessage(); + om.Write("Hi!"); + Net.SendMessage(om, NetDeliveryMethod.ReliableOrdered); + m_lastSent = NetTime.Now; + + // also update title +#if DEBUG + this.Text = Net.Statistics.SentBytes + " bytes sent; " + Net.Statistics.ReceivedBytes + " bytes received"; +#else + string str = Net.ServerConnection == null ? "No connection" : Net.ServerConnection.Status.ToString(); + if (this.Text != str) + this.Text = str; +#endif + } + } + + private void button1_Click(object sender, EventArgs e) + { + var om = Net.CreateMessage(); + om.Write("Hi!"); + + Net.SendMessage(om, NetDeliveryMethod.ReliableOrdered); + } + } +} diff --git a/Samples/LibraryTestSamples/ManySample/ManyClients/Client.resx b/Samples/LibraryTestSamples/ManySample/ManyClients/Client.resx new file mode 100644 index 0000000..ff31a6d --- /dev/null +++ b/Samples/LibraryTestSamples/ManySample/ManyClients/Client.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Samples/LibraryTestSamples/ManySample/ManyClients/Form1.Designer.cs b/Samples/LibraryTestSamples/ManySample/ManyClients/Form1.Designer.cs new file mode 100644 index 0000000..6681597 --- /dev/null +++ b/Samples/LibraryTestSamples/ManySample/ManyClients/Form1.Designer.cs @@ -0,0 +1,75 @@ +namespace ManyClients +{ + partial class Form1 + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.label1 = new System.Windows.Forms.Label(); + this.button1 = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(12, 9); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(38, 13); + this.label1.TabIndex = 0; + this.label1.Text = "label1"; + // + // button1 + // + this.button1.Location = new System.Drawing.Point(63, 44); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(158, 41); + this.button1.TabIndex = 1; + this.button1.Text = "Create new client"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // Form1 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(270, 97); + this.Controls.Add(this.button1); + this.Controls.Add(this.label1); + this.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.Name = "Form1"; + this.Text = "Form1"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Button button1; + } +} + diff --git a/Samples/LibraryTestSamples/ManySample/ManyClients/Form1.cs b/Samples/LibraryTestSamples/ManySample/ManyClients/Form1.cs new file mode 100644 index 0000000..4a8dfd7 --- /dev/null +++ b/Samples/LibraryTestSamples/ManySample/ManyClients/Form1.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Windows.Forms; + +namespace ManyClients +{ + public partial class Form1 : Form + { + public Form1() + { + InitializeComponent(); + } + + private void button1_Click(object sender, EventArgs e) + { + Program.CreateClient(); + } + } +} diff --git a/Samples/LibraryTestSamples/ManySample/ManyClients/Form1.resx b/Samples/LibraryTestSamples/ManySample/ManyClients/Form1.resx new file mode 100644 index 0000000..ff31a6d --- /dev/null +++ b/Samples/LibraryTestSamples/ManySample/ManyClients/Form1.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Samples/LibraryTestSamples/ManySample/ManyClients/ManyClients.csproj b/Samples/LibraryTestSamples/ManySample/ManyClients/ManyClients.csproj new file mode 100644 index 0000000..335be84 --- /dev/null +++ b/Samples/LibraryTestSamples/ManySample/ManyClients/ManyClients.csproj @@ -0,0 +1,103 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {A41772F5-F20F-408D-ABD1-5D1C144853C6} + WinExe + Properties + ManyClients + ManyClients + v3.5 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + 3.5 + + + + + + + + + Form + + + Client.cs + + + Form + + + Form1.cs + + + + + Client.cs + Designer + + + Form1.cs + Designer + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + {AE483C29-042E-4226-BA52-D247CE7676DA} + Lidgren.Network + + + {773069DA-B66E-4667-ADCB-0D215AD8CF3E} + SamplesCommon + + + + + \ No newline at end of file diff --git a/Samples/LibraryTestSamples/ManySample/ManyClients/Program.cs b/Samples/LibraryTestSamples/ManySample/ManyClients/Program.cs new file mode 100644 index 0000000..a2d8ba7 --- /dev/null +++ b/Samples/LibraryTestSamples/ManySample/ManyClients/Program.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Windows.Forms; +using SamplesCommon; + +namespace ManyClients +{ + static class Program + { + public static List Clients; + + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + + Clients = new List(); + + Application.Idle += new EventHandler(AppIdle); + Application.Run(new Form1()); + + foreach (var c in Clients) + c.Shutdown(); + } + + static void AppIdle(object sender, EventArgs e) + { + while (NativeMethods.AppStillIdle) + { + foreach (var c in Clients) + c.Heartbeat(); + System.Threading.Thread.Sleep(1); + } + } + + internal static void CreateClient() + { + Client client = new Client(); + client.Show(); + Clients.Add(client); + } + } +} diff --git a/Samples/LibraryTestSamples/ManySample/ManyClients/Properties/AssemblyInfo.cs b/Samples/LibraryTestSamples/ManySample/ManyClients/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..2fee1ee --- /dev/null +++ b/Samples/LibraryTestSamples/ManySample/ManyClients/Properties/AssemblyInfo.cs @@ -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("ManyClients")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyProduct("ManyClients")] +[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("140e8b00-0bb5-4e9e-847c-56ad106f01a4")] + +// 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")] diff --git a/Samples/LibraryTestSamples/ManySample/ManyClients/Properties/Resources.Designer.cs b/Samples/LibraryTestSamples/ManySample/ManyClients/Properties/Resources.Designer.cs new file mode 100644 index 0000000..1dd11cf --- /dev/null +++ b/Samples/LibraryTestSamples/ManySample/ManyClients/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.4927 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace ManyClients.Properties +{ + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ManyClients.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/Samples/LibraryTestSamples/ManySample/ManyClients/Properties/Resources.resx b/Samples/LibraryTestSamples/ManySample/ManyClients/Properties/Resources.resx new file mode 100644 index 0000000..ffecec8 --- /dev/null +++ b/Samples/LibraryTestSamples/ManySample/ManyClients/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Samples/LibraryTestSamples/ManySample/ManyClients/Properties/Settings.Designer.cs b/Samples/LibraryTestSamples/ManySample/ManyClients/Properties/Settings.Designer.cs new file mode 100644 index 0000000..f6c52b2 --- /dev/null +++ b/Samples/LibraryTestSamples/ManySample/ManyClients/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.4927 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace ManyClients.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "9.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/Samples/LibraryTestSamples/ManySample/ManyClients/Properties/Settings.settings b/Samples/LibraryTestSamples/ManySample/ManyClients/Properties/Settings.settings new file mode 100644 index 0000000..abf36c5 --- /dev/null +++ b/Samples/LibraryTestSamples/ManySample/ManyClients/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Samples/LibraryTestSamples/ManySample/ManySample.sln b/Samples/LibraryTestSamples/ManySample/ManySample.sln new file mode 100644 index 0000000..03c6ae5 --- /dev/null +++ b/Samples/LibraryTestSamples/ManySample/ManySample.sln @@ -0,0 +1,38 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ManyClients", "ManyClients\ManyClients.csproj", "{A41772F5-F20F-408D-ABD1-5D1C144853C6}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ManyServer", "ManyServer\ManyServer.csproj", "{44EFFA4A-C7FC-4C45-B84D-F13A391EF4E7}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SamplesCommon", "..\..\SamplesCommon\SamplesCommon.csproj", "{773069DA-B66E-4667-ADCB-0D215AD8CF3E}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lidgren.Network", "..\..\..\Lidgren.Network\Lidgren.Network.csproj", "{AE483C29-042E-4226-BA52-D247CE7676DA}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A41772F5-F20F-408D-ABD1-5D1C144853C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A41772F5-F20F-408D-ABD1-5D1C144853C6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A41772F5-F20F-408D-ABD1-5D1C144853C6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A41772F5-F20F-408D-ABD1-5D1C144853C6}.Release|Any CPU.Build.0 = Release|Any CPU + {44EFFA4A-C7FC-4C45-B84D-F13A391EF4E7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {44EFFA4A-C7FC-4C45-B84D-F13A391EF4E7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {44EFFA4A-C7FC-4C45-B84D-F13A391EF4E7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {44EFFA4A-C7FC-4C45-B84D-F13A391EF4E7}.Release|Any CPU.Build.0 = Release|Any CPU + {773069DA-B66E-4667-ADCB-0D215AD8CF3E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {773069DA-B66E-4667-ADCB-0D215AD8CF3E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {773069DA-B66E-4667-ADCB-0D215AD8CF3E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {773069DA-B66E-4667-ADCB-0D215AD8CF3E}.Release|Any CPU.Build.0 = Release|Any CPU + {AE483C29-042E-4226-BA52-D247CE7676DA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AE483C29-042E-4226-BA52-D247CE7676DA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AE483C29-042E-4226-BA52-D247CE7676DA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AE483C29-042E-4226-BA52-D247CE7676DA}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Samples/LibraryTestSamples/ManySample/ManyServer/Form1.Designer.cs b/Samples/LibraryTestSamples/ManySample/ManyServer/Form1.Designer.cs new file mode 100644 index 0000000..e7439b3 --- /dev/null +++ b/Samples/LibraryTestSamples/ManySample/ManyServer/Form1.Designer.cs @@ -0,0 +1,64 @@ +namespace ManyServer +{ + partial class Form1 + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.richTextBox1 = new System.Windows.Forms.RichTextBox(); + this.SuspendLayout(); + // + // richTextBox1 + // + this.richTextBox1.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.richTextBox1.Location = new System.Drawing.Point(12, 168); + this.richTextBox1.Name = "richTextBox1"; + this.richTextBox1.Size = new System.Drawing.Size(808, 283); + this.richTextBox1.TabIndex = 0; + this.richTextBox1.Text = ""; + // + // Form1 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(832, 463); + this.Controls.Add(this.richTextBox1); + this.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.Name = "Form1"; + this.Text = "Form1"; + this.ResumeLayout(false); + + } + + #endregion + + public System.Windows.Forms.RichTextBox richTextBox1; + + } +} + diff --git a/Samples/LibraryTestSamples/ManySample/ManyServer/Form1.cs b/Samples/LibraryTestSamples/ManySample/ManyServer/Form1.cs new file mode 100644 index 0000000..ead4937 --- /dev/null +++ b/Samples/LibraryTestSamples/ManySample/ManyServer/Form1.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Windows.Forms; + +namespace ManyServer +{ + public partial class Form1 : Form + { + public Form1() + { + InitializeComponent(); + } + } +} diff --git a/Samples/LibraryTestSamples/ManySample/ManyServer/Form1.resx b/Samples/LibraryTestSamples/ManySample/ManyServer/Form1.resx new file mode 100644 index 0000000..ff31a6d --- /dev/null +++ b/Samples/LibraryTestSamples/ManySample/ManyServer/Form1.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Samples/LibraryTestSamples/ManySample/ManyServer/ManyServer.csproj b/Samples/LibraryTestSamples/ManySample/ManyServer/ManyServer.csproj new file mode 100644 index 0000000..8e568b4 --- /dev/null +++ b/Samples/LibraryTestSamples/ManySample/ManyServer/ManyServer.csproj @@ -0,0 +1,91 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {44EFFA4A-C7FC-4C45-B84D-F13A391EF4E7} + WinExe + Properties + ManyServer + ManyServer + v3.5 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + 3.5 + + + + + + + + Form + + + Form1.cs + + + + + Form1.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + {AE483C29-042E-4226-BA52-D247CE7676DA} + Lidgren.Network + + + {773069DA-B66E-4667-ADCB-0D215AD8CF3E} + SamplesCommon + + + + + \ No newline at end of file diff --git a/Samples/LibraryTestSamples/ManySample/ManyServer/Program.cs b/Samples/LibraryTestSamples/ManySample/ManyServer/Program.cs new file mode 100644 index 0000000..68d16e3 --- /dev/null +++ b/Samples/LibraryTestSamples/ManySample/ManyServer/Program.cs @@ -0,0 +1,81 @@ +using System; +using System.Collections.Generic; +using System.Windows.Forms; + +using Lidgren.Network; +using SamplesCommon; + +namespace ManyServer +{ + static class Program + { + public static Form1 MainForm; + public static NetServer Server; + + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + MainForm = new Form1(); + + NetPeerConfiguration config = new NetPeerConfiguration("many"); + config.Port = 14242; +#if DEBUG + config.SimulatedLoss = 0.02f; +#else + // throw new Exception("Sample not relevant in RELEASE; statistics needed to make sense!"); +#endif + config.MaximumConnections = 64; + + Server = new NetServer(config); + Server.Start(); + + var swin = new NetPeerSettingsWindow("Server settings", Program.Server); + swin.Show(); + + Application.Idle += new EventHandler(AppLoop); + Application.Run(MainForm); + } + + static void AppLoop(object sender, EventArgs e) + { + NetIncomingMessage inc; + + while (NativeMethods.AppStillIdle) + { + // read any pending messages + while ((inc = Server.ReadMessage()) != null) + { + switch (inc.MessageType) + { + case NetIncomingMessageType.DebugMessage: + case NetIncomingMessageType.VerboseDebugMessage: + case NetIncomingMessageType.WarningMessage: + case NetIncomingMessageType.ErrorMessage: + // just print any message + string str = inc.ReadString(); + NativeMethods.AppendText(MainForm.richTextBox1, str); + break; + case NetIncomingMessageType.StatusChanged: + NetConnectionStatus status = (NetConnectionStatus)inc.ReadByte(); + string reason = inc.ReadString(); + NativeMethods.AppendText(MainForm.richTextBox1, NetUtility.ToHexString(inc.SenderConnection.RemoteUniqueIdentifier) + ": " + reason); + MainForm.Text = Server.ConnectionsCount + " connections"; + break; + case NetIncomingMessageType.Data: + string dstr = "Data from " + NetUtility.ToHexString(inc.SenderConnection.RemoteUniqueIdentifier) + ": " + inc.ReadString(); + //NativeMethods.AppendText(MainForm.richTextBox1, dstr); + + NetOutgoingMessage outMsg = Server.CreateMessage(); + outMsg.Write(dstr); + Server.SendMessage(outMsg, Server.Connections, NetDeliveryMethod.ReliableOrdered, 0); + break; + } + } + + System.Threading.Thread.Sleep(1); + } + } + } +} diff --git a/Samples/LibraryTestSamples/ManySample/ManyServer/Properties/AssemblyInfo.cs b/Samples/LibraryTestSamples/ManySample/ManyServer/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..f04c1e7 --- /dev/null +++ b/Samples/LibraryTestSamples/ManySample/ManyServer/Properties/AssemblyInfo.cs @@ -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("ManyServer")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyProduct("ManyServer")] +[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("21b31854-6021-4153-9363-aa7c23a9d997")] + +// 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")] diff --git a/Samples/LibraryTestSamples/ManySample/ManyServer/Properties/Resources.Designer.cs b/Samples/LibraryTestSamples/ManySample/ManyServer/Properties/Resources.Designer.cs new file mode 100644 index 0000000..f649427 --- /dev/null +++ b/Samples/LibraryTestSamples/ManySample/ManyServer/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.4927 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace ManyServer.Properties +{ + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ManyServer.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/Samples/LibraryTestSamples/ManySample/ManyServer/Properties/Resources.resx b/Samples/LibraryTestSamples/ManySample/ManyServer/Properties/Resources.resx new file mode 100644 index 0000000..ffecec8 --- /dev/null +++ b/Samples/LibraryTestSamples/ManySample/ManyServer/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Samples/LibraryTestSamples/ManySample/ManyServer/Properties/Settings.Designer.cs b/Samples/LibraryTestSamples/ManySample/ManyServer/Properties/Settings.Designer.cs new file mode 100644 index 0000000..185da56 --- /dev/null +++ b/Samples/LibraryTestSamples/ManySample/ManyServer/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.4927 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace ManyServer.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "9.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/Samples/LibraryTestSamples/ManySample/ManyServer/Properties/Settings.settings b/Samples/LibraryTestSamples/ManySample/ManyServer/Properties/Settings.settings new file mode 100644 index 0000000..abf36c5 --- /dev/null +++ b/Samples/LibraryTestSamples/ManySample/ManyServer/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + +