Merge branch 'develop' into dokter
This commit is contained in:
@@ -1,11 +1,9 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
using Client;
|
||||
using Newtonsoft.Json;
|
||||
using System.Security.Cryptography;
|
||||
using ClientApp.Utils;
|
||||
|
||||
namespace Server
|
||||
{
|
||||
@@ -77,7 +75,7 @@ namespace Server
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// TODO
|
||||
/// handles all incoming data from the client
|
||||
/// </summary>
|
||||
/// <param name="message">including message length and messageId (can be changed)</param>
|
||||
private void HandleData(byte[] message)
|
||||
@@ -143,7 +141,9 @@ namespace Server
|
||||
}
|
||||
else if (DataParser.isRawData(message))
|
||||
{
|
||||
// print the raw data
|
||||
Console.WriteLine(BitConverter.ToString(payloadbytes));
|
||||
// TODO change, checking for length is not that safe
|
||||
if (payloadbytes.Length == 8)
|
||||
{
|
||||
saveData?.WriteDataRAWBike(payloadbytes);
|
||||
@@ -168,7 +168,6 @@ namespace Server
|
||||
|
||||
private bool verifyLogin(string username, string password)
|
||||
{
|
||||
Console.WriteLine("got hashes " + username + "\n" + password);
|
||||
|
||||
|
||||
if (!File.Exists(fileName))
|
||||
@@ -217,10 +216,6 @@ namespace Server
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static string ByteArrayToString(byte[] ba)
|
||||
{
|
||||
StringBuilder hex = new StringBuilder(ba.Length * 2);
|
||||
|
||||
@@ -63,12 +63,20 @@ namespace Server
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
using (BinaryWriter sw = new BinaryWriter(File.Open(fileLocation, FileMode.Create)))
|
||||
using (var fileStream = new FileStream(fileLocation, FileMode.Append, FileAccess.Write, FileShare.None))
|
||||
using (var bw = new BinaryWriter(fileStream))
|
||||
{
|
||||
sw.Seek(length, SeekOrigin.End);
|
||||
sw.Write(data);
|
||||
sw.Flush();
|
||||
//sw.BaseStream.Seek(length, SeekOrigin.Begin);
|
||||
bw.Write(data);
|
||||
bw.Flush();
|
||||
//Console.WriteLine("wrote at " + bw.BaseStream.Position);
|
||||
}
|
||||
//using (BinaryReader binaryReader = new BinaryReader(File.Open(fileLocation, FileMode.Open)))
|
||||
//{
|
||||
// byte[] totalArray = new byte[binaryReader.BaseStream.Length];
|
||||
// binaryReader.BaseStream.Read(totalArray, 0, (int)binaryReader.BaseStream.Length);
|
||||
// Console.WriteLine("all data is " + BitConverter.ToString(totalArray));
|
||||
//}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -86,6 +94,7 @@ namespace Server
|
||||
{
|
||||
FileInfo fi = new FileInfo(this.path + rawBPMFilename);
|
||||
int length = (int)fi.Length;
|
||||
//Console.WriteLine("length " + length);
|
||||
|
||||
byte[] output = new byte[outputSize];
|
||||
|
||||
@@ -93,15 +102,20 @@ namespace Server
|
||||
int readSize = messageSize * averageOver;
|
||||
byte[] readBuffer = new byte[readSize];
|
||||
|
||||
using (FileStream fileStream = new FileStream(this.path + rawBPMFilename, FileMode.Open, FileAccess.Read))
|
||||
using (BinaryReader binaryReader = new BinaryReader(File.Open(this.path + rawBPMFilename, FileMode.Open)))
|
||||
{
|
||||
for (int i = 1; i >= outputSize; i++)
|
||||
//byte[] totalArray = new byte[binaryReader.BaseStream.Length];
|
||||
//binaryReader.BaseStream.Read(totalArray, 0, (int)binaryReader.BaseStream.Length);
|
||||
//Console.WriteLine("all data is " + BitConverter.ToString(totalArray));
|
||||
for (int i = 1; i <= outputSize; i++)
|
||||
{
|
||||
if (length - (i * readSize) < 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
fileStream.Read(readBuffer, length - (i * readSize), readSize);
|
||||
binaryReader.BaseStream.Seek(length - (i * readSize), SeekOrigin.Begin);
|
||||
binaryReader.BaseStream.Read(readBuffer, 0, readSize);
|
||||
//Console.WriteLine("read " + binaryReader.BaseStream.Position + " and size " + readSize + " with value " + BitConverter.ToString(readBuffer));
|
||||
|
||||
//handling data
|
||||
int total = 0;
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Client\Client.csproj" />
|
||||
<ProjectReference Include="..\ClientApp\ClientApp.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<Import Project="..\Hashing\Hashing.projitems" Label="Shared" />
|
||||
|
||||
Reference in New Issue
Block a user