Implemented the server form. Client <-> Server interaction actually works.
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.
This commit is contained in:
1
TestClient/Form1.Designer.cs
generated
1
TestClient/Form1.Designer.cs
generated
@@ -75,6 +75,7 @@
|
||||
this.serverTextBox.Name = "serverTextBox";
|
||||
this.serverTextBox.Size = new System.Drawing.Size(137, 20);
|
||||
this.serverTextBox.TabIndex = 2;
|
||||
this.serverTextBox.Text = "localhost";
|
||||
//
|
||||
// portNumeric
|
||||
//
|
||||
|
||||
@@ -40,14 +40,13 @@ namespace TestClient
|
||||
InitializeComponent();
|
||||
|
||||
this.connectButton.Click += connectButton_Click;
|
||||
|
||||
this.disconnectButton.Click += disconnectButton_Click;
|
||||
|
||||
|
||||
this.encryptButton.Click += encryptButton_Click;
|
||||
|
||||
this.signButton.Click += signButton_Click;
|
||||
|
||||
this.FormClosing += Form1_FormClosing;
|
||||
|
||||
// --- SSPI ---
|
||||
this.cred = new ClientCredential( SecurityPackage.Negotiate );
|
||||
|
||||
@@ -64,6 +63,7 @@ namespace TestClient
|
||||
|
||||
this.connection = new CustomConnection();
|
||||
this.connection.Received += connection_Received;
|
||||
this.connection.Disconnected += connection_Disconnected;
|
||||
|
||||
// --- UI Fillout ---
|
||||
this.usernameTextbox.Text = this.cred.Name;
|
||||
@@ -71,6 +71,11 @@ namespace TestClient
|
||||
UpdateButtons();
|
||||
}
|
||||
|
||||
private void Form1_FormClosing( object sender, FormClosingEventArgs e )
|
||||
{
|
||||
this.connection.Stop();
|
||||
}
|
||||
|
||||
private void connectButton_Click( object sender, EventArgs e )
|
||||
{
|
||||
if( string.IsNullOrWhiteSpace( this.serverTextBox.Text ) )
|
||||
@@ -82,6 +87,8 @@ namespace TestClient
|
||||
try
|
||||
{
|
||||
this.connection.StartClient( this.serverTextBox.Text, (int)this.portNumeric.Value );
|
||||
this.initializing = true;
|
||||
DoInit();
|
||||
}
|
||||
catch( SocketException socketExcept )
|
||||
{
|
||||
@@ -101,7 +108,6 @@ namespace TestClient
|
||||
}
|
||||
}
|
||||
|
||||
this.initializing = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,6 +180,18 @@ namespace TestClient
|
||||
} );
|
||||
}
|
||||
|
||||
private void connection_Disconnected()
|
||||
{
|
||||
this.connected = false;
|
||||
this.initializing = false;
|
||||
this.lastServerToken = null;
|
||||
|
||||
this.Invoke( (Action)delegate()
|
||||
{
|
||||
UpdateButtons();
|
||||
});
|
||||
}
|
||||
|
||||
private void DoInit()
|
||||
{
|
||||
SecurityStatus status;
|
||||
|
||||
Reference in New Issue
Block a user