Develop #10
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
@@ -55,7 +55,7 @@ namespace Client
|
||||
|
||||
this.stream = this.client.GetStream();
|
||||
|
||||
tryLoginDoctor("hi","hi");
|
||||
tryLogin();
|
||||
|
||||
this.stream.BeginRead(this.buffer, 0, this.buffer.Length, new AsyncCallback(OnRead), null);
|
||||
}
|
||||
@@ -94,7 +94,7 @@ namespace Client
|
||||
if (responseStatus == "OK")
|
||||
{
|
||||
this.connected = true;
|
||||
initEngine();
|
||||
//initEngine();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@ using Hardware.Simulators;
|
||||
using RH_Engine;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
|
||||
namespace Client
|
||||
{
|
||||
@@ -14,6 +15,7 @@ namespace Client
|
||||
Console.WriteLine("Hello World!");
|
||||
//connect fiets?
|
||||
|
||||
Thread.Sleep(20000);
|
||||
Client client = new Client();
|
||||
|
||||
|
||||
|
||||
@@ -18,10 +18,12 @@ namespace DokterApp
|
||||
private IHandler handler = null;
|
||||
private string username;
|
||||
private string password;
|
||||
private Del callback;
|
||||
|
||||
|
||||
public Client(string adress, int port, string username, string password)
|
||||
public Client(string adress, int port, string username, string password, Del callback)
|
||||
{
|
||||
this.callback = callback;
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
this.client = new TcpClient();
|
||||
@@ -82,8 +84,9 @@ namespace DokterApp
|
||||
}
|
||||
else
|
||||
{
|
||||
callback("yeet");
|
||||
Console.WriteLine($"login failed \"{responseStatus}\"");
|
||||
tryLogin();
|
||||
//tryLogin();
|
||||
}
|
||||
break;
|
||||
case DataParser.START_SESSION:
|
||||
@@ -173,14 +176,6 @@ namespace DokterApp
|
||||
private void tryLogin()
|
||||
{
|
||||
//TODO File in lezen
|
||||
/*Console.WriteLine("enter username");
|
||||
string username = Console.ReadLine();
|
||||
Console.WriteLine("enter password");
|
||||
string password = Console.ReadLine();*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
string hashUser = Hashing.Hasher.HashString(username);
|
||||
string hashPassword = Hashing.Hasher.HashString(password);
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel Grid.ColumnSpan="2" Grid.RowSpan="2" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,0,0,0" Orientation="Vertical">
|
||||
<Label Content="Yo dokter login" Margin="0,0,0,20" HorizontalAlignment="Center"/>
|
||||
<Label x:Name="Label" Content="Yo dokter login" Margin="0,0,0,20" HorizontalAlignment="Center"/>
|
||||
<Label Content="Username" HorizontalContentAlignment="Center"/>
|
||||
<TextBox x:Name="Username" TextWrapping="Wrap" Width="120"/>
|
||||
<Label Content="Password" HorizontalContentAlignment="Center"/>
|
||||
|
||||
@@ -20,6 +20,7 @@ namespace DokterApp
|
||||
/// </summary>
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
Del handler;
|
||||
Client client;
|
||||
public MainWindow()
|
||||
{
|
||||
@@ -27,18 +28,27 @@ namespace DokterApp
|
||||
|
||||
}
|
||||
|
||||
private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void Login_Click_1(object sender, RoutedEventArgs e)
|
||||
{
|
||||
WindowTabs windowTabs = new WindowTabs();
|
||||
handler = windowTabs.NewTab;
|
||||
|
||||
this.Label.Content = "Waiting";
|
||||
this.client = new Client("localhost", 5555, this.Username.Text, this.Password.Text, handler);
|
||||
while (!client.IsConnected())
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
windowTabs.Show();
|
||||
this.client = new Client("localhost", 5555, this.Username.Text, this.Password.Text);
|
||||
|
||||
this.Close();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public delegate void Del(string message);
|
||||
}
|
||||
|
||||
@@ -31,14 +31,23 @@ namespace DokterApp
|
||||
|
||||
private void Button_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
TabItem newTabItem = new TabItem
|
||||
{
|
||||
Header = "Test",
|
||||
Width = 110,
|
||||
Height = 40
|
||||
};
|
||||
newTabItem.Content = new UserControlForTab();
|
||||
this.tbControl.Items.Add(newTabItem);
|
||||
NewTab("Test");
|
||||
}
|
||||
|
||||
public void NewTab(string username)
|
||||
{
|
||||
Application.Current.Dispatcher.Invoke((Action)delegate {
|
||||
// your code
|
||||
TabItem newTabItem = new TabItem
|
||||
{
|
||||
Header = username,
|
||||
Width = 110,
|
||||
Height = 40
|
||||
};
|
||||
newTabItem.Content = new UserControlForTab();
|
||||
this.tbControl.Items.Add(newTabItem);
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ namespace Server
|
||||
|
||||
private void OnRead(IAsyncResult ar)
|
||||
{
|
||||
|
||||
int receivedBytes = this.stream.EndRead(ar);
|
||||
|
||||
if (totalBufferReceived + receivedBytes > 1024)
|
||||
@@ -160,7 +161,7 @@ namespace Server
|
||||
|
||||
}
|
||||
|
||||
private void sendMessage(byte[] message)
|
||||
public void sendMessage(byte[] message)
|
||||
{
|
||||
stream.BeginWrite(message, 0, message.Length, new AsyncCallback(OnWrite), null);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using System;
|
||||
using Client;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO.Pipes;
|
||||
using System.Linq;
|
||||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
|
||||
@@ -10,6 +12,7 @@ namespace Server
|
||||
{
|
||||
private TcpListener listener;
|
||||
private List<Client> clients;
|
||||
private Client doctor;
|
||||
|
||||
public Communication(TcpListener listener)
|
||||
{
|
||||
@@ -28,9 +31,19 @@ namespace Server
|
||||
|
||||
private void OnConnect(IAsyncResult ar)
|
||||
{
|
||||
|
||||
var tcpClient = listener.EndAcceptTcpClient(ar);
|
||||
Console.WriteLine($"Client connected from {tcpClient.Client.RemoteEndPoint}");
|
||||
clients.Add(new Client(this, tcpClient));
|
||||
if (doctor == null)
|
||||
{
|
||||
doctor = clients.ElementAt(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
doctor.sendMessage(DataParser.getLoginResponse("new client"));
|
||||
}
|
||||
listener.BeginAcceptTcpClient(new AsyncCallback(OnConnect), null);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user