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

@@ -57,6 +57,9 @@ namespace DoctorApp.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)
@@ -91,7 +94,7 @@ namespace DoctorApp.Utils
Debug.WriteLine("Username and password correct!");
this.LoginViewModel.setLoginStatus(true);
this.connected = true;
}
else
{
@@ -192,7 +195,7 @@ namespace DoctorApp.Utils
/// <param name="bytes">the message</param>
public void Bike(byte[] bytes)
{
if (!sessionRunning)
{
return;
@@ -202,18 +205,18 @@ namespace DoctorApp.Utils
throw new ArgumentNullException("no bytes");
}
byte[] message = DataParser.GetRawDataMessage(bytes);
/* switch (bytes[0])
{
case 0x10:
/* switch (bytes[0])
{
if (canSendToEngine) engineConnection.BikeSpeed = (bytes[4] | (bytes[5] << 8)) * 0.01f;
break;
case 0x19:
if (canSendToEngine) engineConnection.BikePower = (bytes[5]) | (bytes[6] & 0b00001111) << 8;
break;
}*/
case 0x10:
if (canSendToEngine) engineConnection.BikeSpeed = (bytes[4] | (bytes[5] << 8)) * 0.01f;
break;
case 0x19:
if (canSendToEngine) engineConnection.BikePower = (bytes[5]) | (bytes[6] & 0b00001111) << 8;
break;
}*/
this.stream.BeginWrite(message, 0, message.Length, new AsyncCallback(OnWrite), null);
@@ -234,8 +237,8 @@ namespace DoctorApp.Utils
/// </summary>
public void tryLogin(string username, string password)
{
string hashUser = Hasher.HashString(username);
string hashPassword = Hasher.HashString(password);
string hashPassword = Util.Hasher.HashString(password);
byte[] message = DataParser.getJsonMessage(DataParser.GetLoginJson(hashUser, hashPassword));
@@ -266,5 +269,13 @@ namespace DoctorApp.Utils
{
this.ClientInfoViewModel = clientInfoViewModel;
}
public void Dispose()
{
Debug.WriteLine("client dispose called");
this.stream.Dispose();
this.client.Dispose();
this.handler?.stop();
}
}
}