Merge remote-tracking branch 'origin/develop' into dataOnTabs

This commit is contained in:
fabjuuuh
2020-10-19 11:14:57 +02:00
11 changed files with 90 additions and 76 deletions

View File

@@ -1,11 +1,11 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Sockets;
using System.Text;
using Newtonsoft.Json;
using System.Diagnostics;
using Util;
using System.Linq;
namespace Server
{
@@ -93,7 +93,6 @@ namespace Server
string identifier;
bool isJson = DataParser.getJsonIdentifier(message, out identifier);
Debug.WriteLine("server " + Encoding.ASCII.GetString(payloadbytes));
if (isJson)
{
switch (identifier)
@@ -109,7 +108,6 @@ namespace Server
if (handleLogin(payloadbytes))
{
communication.Doctor = this;
Console.WriteLine("Set doctor to " + communication.Doctor + " , this is " + this);
}
break;
case DataParser.START_SESSION:
@@ -120,7 +118,6 @@ namespace Server
break;
case DataParser.SET_RESISTANCE:
bool worked = DataParser.getResistanceFromResponseJson(payloadbytes);
Console.WriteLine($"set resistance worked is " + worked);
//set resistance on doctor GUI
break;
case DataParser.DISCONNECT:
@@ -160,7 +157,6 @@ namespace Server
Console.WriteLine("Log in");
this.username = username;
sendMessage(DataParser.getLoginResponse("OK"));
//sendMessage(DataParser.getStartSessionJson());
return true;
}
else
@@ -177,7 +173,6 @@ namespace Server
public void sendMessage(byte[] message)
{
Debug.WriteLine("serverclient " + Encoding.ASCII.GetString(message.Skip(5).ToArray()));
stream.BeginWrite(message, 0, message.Length, new AsyncCallback(OnWrite), null);
}

View File

@@ -1,10 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO.Pipes;
using System.Linq;
using System.Net.Sockets;
using System.Text;
using Util;
namespace Server
@@ -25,10 +21,7 @@ namespace Server
this.mDoctor = value;
this.clients.ForEach((client) =>
{
Debug.WriteLine("foreach called for " + client.username);
byte[] dinges = DataParser.getNewConnectionJson(client.username);
Debug.WriteLine("foreach " + Encoding.ASCII.GetString(dinges.Skip(5).ToArray()));
this.mDoctor.sendMessage(dinges);
this.mDoctor.sendMessage(DataParser.getNewConnectionJson(client.username));
});
}
}
@@ -65,10 +58,7 @@ namespace Server
public void NewLogin(Client client)
{
this.clients.Add(client);
Debug.WriteLine("amount of clients is now " + this.clients.Count);
var dinges = DataParser.getNewConnectionJson(client.username);
Debug.WriteLine("new login" + Encoding.ASCII.GetString(dinges));
Doctor?.sendMessage(dinges);
Doctor?.sendMessage(DataParser.getNewConnectionJson(client.username));
}
public void LogOff(Client client)
@@ -82,9 +72,9 @@ namespace Server
public void StartSessionUser(string user)
{
foreach(Client client in clients)
foreach (Client client in clients)
{
if(client.username == user)
if (client.username == user)
{
client.sendMessage(DataParser.getStartSessionJson(user));
client.StartSession();