Connections shit
This commit is contained in:
@@ -4,7 +4,7 @@ using System.IO.Pipes;
|
||||
using System.Linq;
|
||||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
using ClientApp.Utils;
|
||||
using DoctorApp.Utils;
|
||||
|
||||
namespace Server
|
||||
{
|
||||
@@ -13,7 +13,6 @@ namespace Server
|
||||
private TcpListener listener;
|
||||
private List<Client> clients;
|
||||
private Client doctor;
|
||||
|
||||
public Communication(TcpListener listener)
|
||||
{
|
||||
this.listener = listener;
|
||||
@@ -35,15 +34,15 @@ namespace Server
|
||||
var tcpClient = listener.EndAcceptTcpClient(ar);
|
||||
Console.WriteLine($"Client connected from {tcpClient.Client.RemoteEndPoint}");
|
||||
clients.Add(new Client(this, tcpClient));
|
||||
if (doctor == null)
|
||||
/*if (doctor == null)
|
||||
{
|
||||
doctor = clients.ElementAt(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
doctor.sendMessage(DataParser.getLoginResponse("new client"));
|
||||
}
|
||||
doctor.sendMessage(DataParser.getNewConnectionJson("jan"));
|
||||
}*/
|
||||
listener.BeginAcceptTcpClient(new AsyncCallback(OnConnect), null);
|
||||
}
|
||||
|
||||
@@ -51,5 +50,18 @@ namespace Server
|
||||
{
|
||||
clients.Remove(client);
|
||||
}
|
||||
|
||||
public void NewLogin(Client client)
|
||||
{
|
||||
if (doctor == null)
|
||||
{
|
||||
doctor = client;
|
||||
}
|
||||
else
|
||||
{
|
||||
doctor.sendMessage(DataParser.getNewConnectionJson(client.username));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user