diff --git a/Server/Client.cs b/Server/Client.cs index 3843f52..2184dcf 100644 --- a/Server/Client.cs +++ b/Server/Client.cs @@ -100,9 +100,14 @@ namespace Server handleLogin(payloadbytes); break; case DataParser.LOGIN_DOCTOR: - handleLogin(payloadbytes); - communication.doctor = this; - Console.WriteLine("Set doctor to " + communication.doctor + " , this is " + this); + if (communication.doctor != null) + return; + + if (handleLogin(payloadbytes)) + { + communication.doctor = this; + Console.WriteLine("Set doctor to " + communication.doctor + " , this is " + this); + } break; case DataParser.START_SESSION: this.saveData = new SaveData(Directory.GetCurrentDirectory() + "/" + this.username + "/" + sessionStart.ToString("yyyy-MM-dd HH-mm-ss")); @@ -150,7 +155,7 @@ namespace Server } - private void handleLogin(byte[] payloadbytes) + private bool handleLogin(byte[] payloadbytes) { string username; string password; @@ -164,6 +169,7 @@ namespace Server sendMessage(DataParser.getLoginResponse("OK")); sendMessage(DataParser.getStartSessionJson()); communication.NewLogin(this); + return true; } else { @@ -174,6 +180,7 @@ namespace Server { sendMessage(DataParser.getLoginResponse("invalid json")); } + return false; } public void sendMessage(byte[] message)