This commit is contained in:
shinichi
2020-10-29 17:01:14 +01:00
parent da9d3184a1
commit 6d599cfcd2
6 changed files with 82 additions and 26 deletions

View File

@@ -147,6 +147,25 @@ namespace Server
case DataParser.MESSAGE:
communication.SendMessageToClient(DataParser.getUsernameFromJson(payloadbytes), message);
break;
case DataParser.GET_FILE:
//ugly
string username = DataParser.GetUsernameFromGetFileBytes(payloadbytes);
string path = Directory.GetCurrentDirectory() + "/" + username + "/" + DataParser.GetDateFromGetFileBytes(payloadbytes) + "/rawBike.bin";
int length = Int32.MaxValue;
try
{
FileInfo fi = new FileInfo(path);
length = (int)fi.Length;
}
catch
{
Console.WriteLine("couldn't find file " + path);
}
if (length > 10240)
break;
communication.SendMessageToClient(username, DataParser.GetFileMessage(File.ReadAllBytes(path)));
break;
default:
Console.WriteLine($"Received json with identifier {identifier}:\n{Encoding.ASCII.GetString(payloadbytes)}");
break;