connectie met server

This commit is contained in:
fabjuuuh
2020-10-07 13:21:30 +02:00
parent a2937c0427
commit aea1b4fce4
8 changed files with 434 additions and 28 deletions

View File

@@ -6,7 +6,7 @@ using ProftaakRH;
namespace Client
{
class Client : IDataReceiver
public class Client : IDataReceiver
{
private TcpClient client;
private NetworkStream stream;
@@ -55,7 +55,7 @@ namespace Client
this.stream = this.client.GetStream();
tryLogin();
tryLoginDoctor("hi","hi");
this.stream.BeginRead(this.buffer, 0, this.buffer.Length, new AsyncCallback(OnRead), null);
}
@@ -203,6 +203,17 @@ namespace Client
this.stream.BeginWrite(message, 0, message.Length, new AsyncCallback(OnWrite), null);
}
public void tryLoginDoctor(string username, string password)
{
string hashUser = Hashing.Hasher.HashString(username);
string hashPassword = Hashing.Hasher.HashString(password);
byte[] message = DataParser.getJsonMessage(DataParser.GetLoginJson(hashUser, hashPassword));
stream.BeginWrite(message, 0, message.Length, new AsyncCallback(OnWrite), null);
}
public void setHandler(IHandler handler)
{
this.handler = handler;