This commit is contained in:
fabjuuuh
2020-10-16 15:02:26 +02:00
parent e3c580c8c2
commit 173dbf2745
8 changed files with 47 additions and 16 deletions

View File

@@ -3,7 +3,6 @@ using System.IO;
using System.Net.Sockets;
using System.Text;
using Newtonsoft.Json;
using ClientApp.Utils;
using System.Diagnostics;
using Util;
@@ -110,10 +109,10 @@ namespace Server
}
break;
case DataParser.START_SESSION:
this.saveData = new SaveData(Directory.GetCurrentDirectory() + "/" + this.username + "/" + sessionStart.ToString("yyyy-MM-dd HH-mm-ss"));
this.communication.StartSessionUser(DataParser.getUsernameFromJson(payloadbytes));
break;
case DataParser.STOP_SESSION:
this.saveData = null;
this.communication.StopSessionUser(DataParser.getUsernameFromJson(payloadbytes));
break;
case DataParser.SET_RESISTANCE:
bool worked = DataParser.getResistanceFromResponseJson(payloadbytes);
@@ -242,5 +241,15 @@ namespace Server
hex.AppendFormat("{0:x2}", b);
return hex.ToString();
}
public void StartSession()
{
this.saveData = new SaveData(Directory.GetCurrentDirectory() + "/" + this.username + "/" + sessionStart.ToString("yyyy-MM-dd HH-mm-ss"));
}
public void StopSession()
{
this.saveData = null;
}
}
}

View File

@@ -4,7 +4,6 @@ using System.IO.Pipes;
using System.Linq;
using System.Net.Sockets;
using System.Text;
using DoctorApp.Utils;
using Util;
namespace Server
@@ -56,5 +55,30 @@ namespace Server
}
}
public void StartSessionUser(string user)
{
foreach(Client client in clients)
{
if(client.username == user)
{
client.sendMessage(DataParser.getStartSessionJson(user));
client.StartSession();
}
}
}
public void StopSessionUser(string user)
{
foreach (Client client in clients)
{
if (client.username == user)
{
client.sendMessage(DataParser.getStopSessionJson(user));
client.StopSession();
}
}
}
}
}