diff --git a/ClientApp/Utils/Client.cs b/ClientApp/Utils/Client.cs
index 16527fd..7a4dd03 100644
--- a/ClientApp/Utils/Client.cs
+++ b/ClientApp/Utils/Client.cs
@@ -10,7 +10,7 @@ using Util;
namespace ClientApp.Utils
{
public delegate void EngineCallback();
- public class Client : IDataReceiver
+ public class Client : IDataReceiver, IDisposable
{
public EngineCallback engineConnectFailed;
public EngineCallback engineConnectSuccess;
@@ -87,6 +87,10 @@ namespace ClientApp.Utils
/// the result of the async read
private void OnRead(IAsyncResult ar)
{
+ if (ar == null || (!ar.IsCompleted))
+ return;
+
+
int receivedBytes = this.stream.EndRead(ar);
if (totalBufferReceived + receivedBytes > 1024)
@@ -122,7 +126,7 @@ namespace ClientApp.Utils
this.LoginViewModel.setLoginStatus(true);
this.connected = true;
initEngine();
-
+
}
else
{
@@ -224,7 +228,7 @@ namespace ClientApp.Utils
/// the message
public void Bike(byte[] bytes)
{
-
+
if (!sessionRunning)
{
return;
@@ -266,7 +270,7 @@ namespace ClientApp.Utils
///
public void tryLogin(string username, string password)
{
-
+
string hashPassword = Util.Hasher.HashString(password);
byte[] message = DataParser.getJsonMessage(DataParser.GetLoginJson(username, hashPassword));
@@ -288,5 +292,13 @@ namespace ClientApp.Utils
{
this.LoginViewModel = loginViewModel;
}
+
+ public void Dispose()
+ {
+ Debug.WriteLine("client dispose called");
+ this.stream.Dispose();
+ this.client.Dispose();
+ this.handler.stop();
+ }
}
}
diff --git a/ClientApp/ViewModels/MainWindowViewModel.cs b/ClientApp/ViewModels/MainWindowViewModel.cs
index 56b98c1..b5caccc 100644
--- a/ClientApp/ViewModels/MainWindowViewModel.cs
+++ b/ClientApp/ViewModels/MainWindowViewModel.cs
@@ -118,6 +118,8 @@ namespace ClientApp.ViewModels
this.MenuCommand = new RelayCommand(() => SystemCommands.ShowSystemMenu(this.mWindow, GetMousePosition()));
var resizer = new WindowResizer(this.mWindow);
+
+ this.mWindow.Closed += (sender, e) => this.client.Dispose();
}
diff --git a/Hashing/Hashing.projitems b/Hashing/Hashing.projitems
index a81b09e..662f597 100644
--- a/Hashing/Hashing.projitems
+++ b/Hashing/Hashing.projitems
@@ -13,4 +13,26 @@
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
\ No newline at end of file
diff --git a/ClientApp/Styles/Buttons.xaml b/Hashing/Styles/Buttons.xaml
similarity index 100%
rename from ClientApp/Styles/Buttons.xaml
rename to Hashing/Styles/Buttons.xaml
diff --git a/ClientApp/Styles/Colors.xaml b/Hashing/Styles/Colors.xaml
similarity index 100%
rename from ClientApp/Styles/Colors.xaml
rename to Hashing/Styles/Colors.xaml
diff --git a/ClientApp/Styles/Fonts.xaml b/Hashing/Styles/Fonts.xaml
similarity index 100%
rename from ClientApp/Styles/Fonts.xaml
rename to Hashing/Styles/Fonts.xaml
diff --git a/ClientApp/Styles/Texts.xaml b/Hashing/Styles/Texts.xaml
similarity index 100%
rename from ClientApp/Styles/Texts.xaml
rename to Hashing/Styles/Texts.xaml
diff --git a/ClientApp/Styles/Windows.xaml b/Hashing/Styles/Windows.xaml
similarity index 100%
rename from ClientApp/Styles/Windows.xaml
rename to Hashing/Styles/Windows.xaml
diff --git a/Server/Client.cs b/Server/Client.cs
index 092fe70..78a1e02 100644
--- a/Server/Client.cs
+++ b/Server/Client.cs
@@ -34,14 +34,16 @@ namespace Server
private void OnRead(IAsyncResult ar)
{
-
+ if (ar == null || (!ar.IsCompleted))
+ return;
+
int receivedBytes = this.stream.EndRead(ar);
if (totalBufferReceived + receivedBytes > 1024)
- if (totalBufferReceived + receivedBytes > 1024)
- {
- throw new OutOfMemoryException("buffer too small");
- }
+ if (totalBufferReceived + receivedBytes > 1024)
+ {
+ throw new OutOfMemoryException("buffer too small");
+ }
Array.Copy(buffer, 0, totalBuffer, totalBufferReceived, receivedBytes);
totalBufferReceived += receivedBytes;
@@ -209,7 +211,7 @@ namespace Server
}
-
+
}