Fixed a few bugs in the CustomServer - wasn't configuring the listen socket correctly, doing read/write operations from the wrong socket, etc. Reworked how the CustomConnection class handles serialization. Added Disconnected events to the sample's CustomConnection and CustomServer classes so the forms could reset state.
283 lines
14 KiB
C#
283 lines
14 KiB
C#
namespace TestClient
|
|
{
|
|
partial class Form1
|
|
{
|
|
/// <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.label1 = new System.Windows.Forms.Label();
|
|
this.label2 = new System.Windows.Forms.Label();
|
|
this.serverTextBox = new System.Windows.Forms.TextBox();
|
|
this.portNumeric = new System.Windows.Forms.NumericUpDown();
|
|
this.connectButton = new System.Windows.Forms.Button();
|
|
this.usernameTextbox = new System.Windows.Forms.TextBox();
|
|
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
|
this.label3 = new System.Windows.Forms.Label();
|
|
this.sendTextbox = new System.Windows.Forms.TextBox();
|
|
this.encryptButton = new System.Windows.Forms.Button();
|
|
this.groupBox2 = new System.Windows.Forms.GroupBox();
|
|
this.signButton = new System.Windows.Forms.Button();
|
|
this.receiveTextbox = new System.Windows.Forms.TextBox();
|
|
this.groupBox3 = new System.Windows.Forms.GroupBox();
|
|
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
|
|
this.disconnectButton = new System.Windows.Forms.Button();
|
|
((System.ComponentModel.ISupportInitialize)(this.portNumeric)).BeginInit();
|
|
this.groupBox1.SuspendLayout();
|
|
this.groupBox2.SuspendLayout();
|
|
this.groupBox3.SuspendLayout();
|
|
this.tableLayoutPanel1.SuspendLayout();
|
|
this.SuspendLayout();
|
|
//
|
|
// label1
|
|
//
|
|
this.label1.AutoSize = true;
|
|
this.label1.Location = new System.Drawing.Point(13, 13);
|
|
this.label1.Name = "label1";
|
|
this.label1.Size = new System.Drawing.Size(41, 13);
|
|
this.label1.TabIndex = 0;
|
|
this.label1.Text = "Server:";
|
|
//
|
|
// label2
|
|
//
|
|
this.label2.AutoSize = true;
|
|
this.label2.Location = new System.Drawing.Point(13, 40);
|
|
this.label2.Name = "label2";
|
|
this.label2.Size = new System.Drawing.Size(29, 13);
|
|
this.label2.TabIndex = 1;
|
|
this.label2.Text = "Port:";
|
|
//
|
|
// serverTextBox
|
|
//
|
|
this.serverTextBox.Location = new System.Drawing.Point(60, 10);
|
|
this.serverTextBox.Name = "serverTextBox";
|
|
this.serverTextBox.Size = new System.Drawing.Size(137, 20);
|
|
this.serverTextBox.TabIndex = 2;
|
|
this.serverTextBox.Text = "localhost";
|
|
//
|
|
// portNumeric
|
|
//
|
|
this.portNumeric.Location = new System.Drawing.Point(60, 40);
|
|
this.portNumeric.Maximum = new decimal(new int[] {
|
|
65536,
|
|
0,
|
|
0,
|
|
0});
|
|
this.portNumeric.Minimum = new decimal(new int[] {
|
|
1,
|
|
0,
|
|
0,
|
|
0});
|
|
this.portNumeric.Name = "portNumeric";
|
|
this.portNumeric.Size = new System.Drawing.Size(82, 20);
|
|
this.portNumeric.TabIndex = 3;
|
|
this.portNumeric.Value = new decimal(new int[] {
|
|
10000,
|
|
0,
|
|
0,
|
|
0});
|
|
//
|
|
// connectButton
|
|
//
|
|
this.connectButton.Location = new System.Drawing.Point(224, 8);
|
|
this.connectButton.Name = "connectButton";
|
|
this.connectButton.Size = new System.Drawing.Size(75, 23);
|
|
this.connectButton.TabIndex = 4;
|
|
this.connectButton.Text = "Connect..";
|
|
this.connectButton.UseVisualStyleBackColor = true;
|
|
//
|
|
// usernameTextbox
|
|
//
|
|
this.usernameTextbox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
|
| System.Windows.Forms.AnchorStyles.Right)));
|
|
this.usernameTextbox.Location = new System.Drawing.Point(82, 27);
|
|
this.usernameTextbox.Name = "usernameTextbox";
|
|
this.usernameTextbox.ReadOnly = true;
|
|
this.usernameTextbox.Size = new System.Drawing.Size(229, 20);
|
|
this.usernameTextbox.TabIndex = 5;
|
|
//
|
|
// groupBox1
|
|
//
|
|
this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
|
| System.Windows.Forms.AnchorStyles.Right)));
|
|
this.groupBox1.Controls.Add(this.label3);
|
|
this.groupBox1.Controls.Add(this.usernameTextbox);
|
|
this.groupBox1.Location = new System.Drawing.Point(335, 10);
|
|
this.groupBox1.Name = "groupBox1";
|
|
this.groupBox1.Size = new System.Drawing.Size(317, 74);
|
|
this.groupBox1.TabIndex = 6;
|
|
this.groupBox1.TabStop = false;
|
|
this.groupBox1.Text = "Client credentials";
|
|
//
|
|
// label3
|
|
//
|
|
this.label3.AutoSize = true;
|
|
this.label3.Location = new System.Drawing.Point(6, 30);
|
|
this.label3.Name = "label3";
|
|
this.label3.Size = new System.Drawing.Size(58, 13);
|
|
this.label3.TabIndex = 6;
|
|
this.label3.Text = "Username:";
|
|
//
|
|
// sendTextbox
|
|
//
|
|
this.sendTextbox.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.sendTextbox.Location = new System.Drawing.Point(6, 19);
|
|
this.sendTextbox.Multiline = true;
|
|
this.sendTextbox.Name = "sendTextbox";
|
|
this.sendTextbox.Size = new System.Drawing.Size(302, 298);
|
|
this.sendTextbox.TabIndex = 7;
|
|
//
|
|
// encryptButton
|
|
//
|
|
this.encryptButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
|
this.encryptButton.Location = new System.Drawing.Point(6, 325);
|
|
this.encryptButton.Name = "encryptButton";
|
|
this.encryptButton.Size = new System.Drawing.Size(126, 23);
|
|
this.encryptButton.TabIndex = 8;
|
|
this.encryptButton.Text = "Encrypt and send";
|
|
this.encryptButton.UseVisualStyleBackColor = true;
|
|
//
|
|
// groupBox2
|
|
//
|
|
this.groupBox2.Controls.Add(this.signButton);
|
|
this.groupBox2.Controls.Add(this.sendTextbox);
|
|
this.groupBox2.Controls.Add(this.encryptButton);
|
|
this.groupBox2.Dock = System.Windows.Forms.DockStyle.Fill;
|
|
this.groupBox2.Location = new System.Drawing.Point(3, 3);
|
|
this.groupBox2.Name = "groupBox2";
|
|
this.groupBox2.Size = new System.Drawing.Size(314, 357);
|
|
this.groupBox2.TabIndex = 9;
|
|
this.groupBox2.TabStop = false;
|
|
this.groupBox2.Text = "Send a message to the server";
|
|
//
|
|
// signButton
|
|
//
|
|
this.signButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
|
this.signButton.Location = new System.Drawing.Point(138, 325);
|
|
this.signButton.Name = "signButton";
|
|
this.signButton.Size = new System.Drawing.Size(118, 23);
|
|
this.signButton.TabIndex = 9;
|
|
this.signButton.Text = "Sign and send";
|
|
this.signButton.UseVisualStyleBackColor = true;
|
|
//
|
|
// receiveTextbox
|
|
//
|
|
this.receiveTextbox.Dock = System.Windows.Forms.DockStyle.Fill;
|
|
this.receiveTextbox.Location = new System.Drawing.Point(3, 16);
|
|
this.receiveTextbox.Multiline = true;
|
|
this.receiveTextbox.Name = "receiveTextbox";
|
|
this.receiveTextbox.Size = new System.Drawing.Size(308, 338);
|
|
this.receiveTextbox.TabIndex = 10;
|
|
//
|
|
// groupBox3
|
|
//
|
|
this.groupBox3.Controls.Add(this.receiveTextbox);
|
|
this.groupBox3.Dock = System.Windows.Forms.DockStyle.Fill;
|
|
this.groupBox3.Location = new System.Drawing.Point(323, 3);
|
|
this.groupBox3.Name = "groupBox3";
|
|
this.groupBox3.Size = new System.Drawing.Size(314, 357);
|
|
this.groupBox3.TabIndex = 11;
|
|
this.groupBox3.TabStop = false;
|
|
this.groupBox3.Text = "Receive messages from the server";
|
|
//
|
|
// tableLayoutPanel1
|
|
//
|
|
this.tableLayoutPanel1.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.tableLayoutPanel1.ColumnCount = 2;
|
|
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
|
|
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
|
|
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F));
|
|
this.tableLayoutPanel1.Controls.Add(this.groupBox2, 0, 0);
|
|
this.tableLayoutPanel1.Controls.Add(this.groupBox3, 1, 0);
|
|
this.tableLayoutPanel1.Location = new System.Drawing.Point(12, 99);
|
|
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
|
|
this.tableLayoutPanel1.RowCount = 1;
|
|
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
|
this.tableLayoutPanel1.Size = new System.Drawing.Size(640, 363);
|
|
this.tableLayoutPanel1.TabIndex = 12;
|
|
//
|
|
// disconnectButton
|
|
//
|
|
this.disconnectButton.Location = new System.Drawing.Point(224, 36);
|
|
this.disconnectButton.Name = "disconnectButton";
|
|
this.disconnectButton.Size = new System.Drawing.Size(75, 23);
|
|
this.disconnectButton.TabIndex = 13;
|
|
this.disconnectButton.Text = "Disconnect";
|
|
this.disconnectButton.UseVisualStyleBackColor = true;
|
|
//
|
|
// Form1
|
|
//
|
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
this.ClientSize = new System.Drawing.Size(664, 472);
|
|
this.Controls.Add(this.disconnectButton);
|
|
this.Controls.Add(this.tableLayoutPanel1);
|
|
this.Controls.Add(this.groupBox1);
|
|
this.Controls.Add(this.connectButton);
|
|
this.Controls.Add(this.portNumeric);
|
|
this.Controls.Add(this.serverTextBox);
|
|
this.Controls.Add(this.label2);
|
|
this.Controls.Add(this.label1);
|
|
this.Name = "Form1";
|
|
this.Text = "Form1";
|
|
((System.ComponentModel.ISupportInitialize)(this.portNumeric)).EndInit();
|
|
this.groupBox1.ResumeLayout(false);
|
|
this.groupBox1.PerformLayout();
|
|
this.groupBox2.ResumeLayout(false);
|
|
this.groupBox2.PerformLayout();
|
|
this.groupBox3.ResumeLayout(false);
|
|
this.groupBox3.PerformLayout();
|
|
this.tableLayoutPanel1.ResumeLayout(false);
|
|
this.ResumeLayout(false);
|
|
this.PerformLayout();
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
private System.Windows.Forms.Label label1;
|
|
private System.Windows.Forms.Label label2;
|
|
private System.Windows.Forms.TextBox serverTextBox;
|
|
private System.Windows.Forms.NumericUpDown portNumeric;
|
|
private System.Windows.Forms.Button connectButton;
|
|
private System.Windows.Forms.TextBox usernameTextbox;
|
|
private System.Windows.Forms.GroupBox groupBox1;
|
|
private System.Windows.Forms.Label label3;
|
|
private System.Windows.Forms.TextBox sendTextbox;
|
|
private System.Windows.Forms.Button encryptButton;
|
|
private System.Windows.Forms.GroupBox groupBox2;
|
|
private System.Windows.Forms.Button signButton;
|
|
private System.Windows.Forms.TextBox receiveTextbox;
|
|
private System.Windows.Forms.GroupBox groupBox3;
|
|
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
|
|
private System.Windows.Forms.Button disconnectButton;
|
|
}
|
|
}
|
|
|