Esempio n. 1
0
        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();
            }
        }
Esempio n. 2
0
        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();
            }
        }
Esempio n. 3
0
        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();
        }
Esempio n. 4
0
        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);
            }
        }
Esempio n. 5
0
 internal void RemoveActiveSession(ClientThread clientThread)
 {
     clients.Remove(clientThread);
 }
Esempio n. 6
0
 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();
 }
Esempio n. 7
0
 internal void RemoveActiveSession(ClientThread clientThread)
 {
     clients.Remove(clientThread);
 }
Esempio n. 8
0
        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);
            }
        }