Develop #10

Merged
SemvdH merged 229 commits from develop into master 2020-10-29 22:50:49 +00:00
3 changed files with 30 additions and 7 deletions
Showing only changes of commit aa5ea7a3e0 - Show all commits

View File

@@ -129,7 +129,7 @@ namespace DoctorApp.Utils
{
MainViewModel.TransferDataToClientBPM(payloadbytes);
}
Array.Copy(totalBuffer, expectedMessageLength, totalBuffer, 0, (totalBufferReceived - expectedMessageLength)); //maybe unsafe idk
totalBufferReceived -= expectedMessageLength;
expectedMessageLength = BitConverter.ToInt32(totalBuffer, 0);
}

View File

@@ -4,9 +4,11 @@ using System;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Printing.IndexedProperties;
using System.Runtime.InteropServices.WindowsRuntime;
using System.Security.Cryptography;
using System.Text;
using System.Windows.Media.Animation;
namespace Util
{
@@ -289,8 +291,12 @@ namespace Util
private static byte[] GetRawDataDoctor(byte[] payload, string username, byte messageID)
{
return getMessage(payload.Concat(Encoding.ASCII.GetBytes(username)).ToArray(), messageID);
Debug.WriteLine(BitConverter.ToString(Encoding.ASCII.GetBytes(username)));
byte[] nameArray = Encoding.ASCII.GetBytes(username);
byte[] total = new byte[nameArray.Length + payload.Length];
Array.Copy(payload, 0, total, 0, payload.Length);
Array.Copy(nameArray,0,total,payload.Length,nameArray.Length);
return getMessage(total,messageID);
}
/// <summary>

View File

@@ -25,6 +25,8 @@ namespace Server
private Timer timer;
private byte[] BikeDataBuffer;
private byte[] BPMDataBuffer;
private bool BPMdata = false;
private bool Bikedata = false;
public Client(Communication communication, TcpClient tcpClient)
{
@@ -153,15 +155,19 @@ namespace Server
}
else if (DataParser.isRawDataBikeServer(message))
{
{
Bikedata = true;
saveData?.WriteDataRAWBike(payloadbytes);
Array.Copy(this.BikeDataBuffer, 0, this.BikeDataBuffer, 8, 8);
Array.Copy(payloadbytes, 0, this.BikeDataBuffer, 0, 8);
this.communication.Doctor?.sendMessage(DataParser.GetRawBikeDataDoctor(payloadbytes, this.username));
}
else if (DataParser.isRawDataBPMServer(message))
{
BPMdata = true;
saveData?.WriteDataRAWBPM(payloadbytes);
Array.Copy(payloadbytes, 0, this.BikeDataBuffer, 0, 2);
this.communication.Doctor?.sendMessage(DataParser.GetRawBPMDataDoctor(payloadbytes, this.username));
}
}
@@ -264,9 +270,20 @@ namespace Server
private void SendDataToDoctor(object sender, ElapsedEventArgs e)
{
this.communication.Doctor?.sendMessage(DataParser.GetRawBikeDataDoctor(this.BikeDataBuffer.Take(8).ToArray(), this.username));
this.communication.Doctor?.sendMessage(DataParser.GetRawBikeDataDoctor(this.BikeDataBuffer.Skip(8).ToArray(), this.username));
this.communication.Doctor?.sendMessage(DataParser.GetRawBikeDataDoctor(this.BikeDataBuffer, this.username));
/*if (Bikedata)
{
this.communication.Doctor?.sendMessage(DataParser.GetRawBikeDataDoctor(this.BikeDataBuffer.Take(8).ToArray(), this.username));
this.communication.Doctor?.sendMessage(DataParser.GetRawBikeDataDoctor(this.BikeDataBuffer.Skip(8).ToArray(), this.username));
Bikedata = false;
}
if (BPMdata)
{
this.communication.Doctor?.sendMessage(DataParser.GetRawBPMDataDoctor(this.BPMDataBuffer, this.username));
BPMdata = false;
}*/
}
}
}