Merge remote-tracking branch 'origin/develop' into newDoctor

This commit is contained in:
fabjuuuh
2020-10-16 12:51:42 +02:00
35 changed files with 1269 additions and 113 deletions

View File

@@ -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;
@@ -46,6 +46,7 @@ namespace ClientApp.Utils
engineConnection = EngineConnection.INSTANCE;
engineConnection.OnNoTunnelId = RetryEngineConnection;
engineConnection.OnSuccessFullConnection = engineConnected;
engineConnection.OnEngineDisconnect = RetryEngineConnection;
if (!engineConnection.Connected) engineConnection.Connect();
}
@@ -87,6 +88,10 @@ namespace ClientApp.Utils
/// <param name="ar">the result of the async read</param>
private void OnRead(IAsyncResult ar)
{
if (ar == null || (!ar.IsCompleted) || (!this.stream.CanRead))
return;
int receivedBytes = this.stream.EndRead(ar);
if (totalBufferReceived + receivedBytes > 1024)
@@ -122,7 +127,7 @@ namespace ClientApp.Utils
this.LoginViewModel.setLoginStatus(true);
this.connected = true;
initEngine();
}
else
{
@@ -224,7 +229,7 @@ namespace ClientApp.Utils
/// <param name="bytes">the message</param>
public void Bike(byte[] bytes)
{
if (!sessionRunning)
{
return;
@@ -266,7 +271,7 @@ namespace ClientApp.Utils
/// </summary>
public void tryLogin(string username, string password)
{
string hashPassword = Util.Hasher.HashString(password);
byte[] message = DataParser.getJsonMessage(DataParser.GetLoginJson(username, hashPassword));
@@ -288,5 +293,13 @@ namespace ClientApp.Utils
{
this.LoginViewModel = loginViewModel;
}
public void Dispose()
{
Debug.WriteLine("client dispose called");
this.stream.Dispose();
this.client.Dispose();
this.handler.stop();
}
}
}