public Server() { AppDomain.CurrentDomain.ProcessExit += new EventHandler(OnProcessExit); FileHandler.CheckStorage(); users = FileHandler.LoadUsers(); TcpListener listener = new TcpListener(NetHelper.GetIP("127.0.0.1"), 8888); //TcpListener listener = new TcpListener(NetHelper.GetIP(GetIp()), 8888); listener.Start(); Console.WriteLine("Server started successfully..."); while (true) { Console.WriteLine("Waiting for connection with client..."); //AcceptTcpClient waits for a connection from the client TcpClient client = listener.AcceptTcpClient(); Console.WriteLine("Client connected"); //Start new client ClientThread cl = new ClientThread(client, this); clients.Add(cl); //Run client on new thread Thread thread = new Thread(new ThreadStart(cl.run)); thread.IsBackground = true; thread.Start(); } }
public void ChangeClientToDoctor(TcpClient client, ClientThread clth) { clients.Remove(clth); doctor = new DoctorThread(client, this); Thread thread = new Thread(new ThreadStart(doctor.run)); thread.IsBackground = true; thread.Start(); }
public void ChangeClientToDoctor(TcpClient client, ClientThread clth) { clients.Remove(clth); doctor = new DoctorThread(client, this); Thread thread = new Thread(new ThreadStart(doctor.run)); thread.IsBackground = true; thread.Start(); foreach (NetCommand command in backlog) { SendToDoctor(command); Thread.Sleep(5); } }
internal void RemoveActiveSession(ClientThread clientThread) { clients.Remove(clientThread); }
public void ChangeClientToDoctor(TcpClient client, ClientThread clth) { clients.Remove(clth); doctor = new DoctorThread(client, this); Thread thread = new Thread(new ThreadStart(doctor.run)); thread.IsBackground = true; thread.Start(); foreach(NetCommand command in backlog) { SendToDoctor(command); Thread.Sleep(5); } }