Progress with structure to send data

This commit is contained in:
fabjuuuh
2020-10-16 16:23:50 +02:00
parent e8a4901f09
commit 5751bbed81
6 changed files with 134 additions and 25 deletions

View File

@@ -6,6 +6,14 @@
<UseWPF>true</UseWPF>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AsyncAwaitBestPractices.MVVM" Version="4.3.0" />
<PackageReference Include="MvvmLightLibsStd10" Version="5.4.1.1" />

View File

@@ -123,13 +123,14 @@ namespace DoctorApp.Utils
break;
}
}
else if (DataParser.isRawData(messageBytes))
else if (DataParser.isRawDataBikeDoctor(messageBytes))
{
Console.WriteLine($"Received data: {BitConverter.ToString(payloadbytes)}");
MainViewModel.TransferDataToClientBike(payloadbytes);
}
else if (DataParser.isRawDataBPMDoctor(messageBytes))
{
MainViewModel.TransferDataToClientBPM(payloadbytes);
}
totalBufferReceived -= expectedMessageLength;
expectedMessageLength = BitConverter.ToInt32(totalBuffer, 0);
}
this.stream.BeginRead(this.buffer, 0, this.buffer.Length, new AsyncCallback(OnRead), null);

View File

@@ -76,6 +76,18 @@ namespace DoctorApp.ViewModels
}
public void BPMData(byte [] bytes)
{
//TODO
//Parsen van de data you fuck
}
public void BikeData(byte[] bytes)
{
//TODO
//Parsen van de data you fuck
}
}
}

View File

@@ -3,6 +3,7 @@ using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Security.Cryptography;
using System.Text;
using System.Windows.Controls;
using Util;
@@ -51,6 +52,30 @@ namespace DoctorApp.ViewModels
}
});
}
public void TransferDataToClientBike(byte[] bytes)
{
string username = DataParser.getNameFromBytes(bytes);
foreach(ClientInfoViewModel item in Tabs)
{
if(item.Username == username)
{
item.BikeData(bytes);
}
}
}
public void TransferDataToClientBPM(byte[] bytes)
{
string username = DataParser.getNameFromBytes(bytes);
foreach (ClientInfoViewModel item in Tabs)
{
if (item.Username == username)
{
item.BikeData(bytes);
}
}
}
}