コード例 #1
0
ファイル: Server.cs プロジェクト: Aaldert/IP2
        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();
            }
        }
コード例 #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();
            }
        }
コード例 #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();
        }
コード例 #4
0
ファイル: Server.cs プロジェクト: kennyboy55/ErgometerIPR
        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);
            }
        }
コード例 #5
0
 internal void RemoveActiveSession(ClientThread clientThread)
 {
     clients.Remove(clientThread);
 }
コード例 #6
0
ファイル: Server.cs プロジェクト: Aaldert/IP2
 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();
 }
コード例 #7
0
ファイル: Server.cs プロジェクト: Aaldert/IP2
 internal void RemoveActiveSession(ClientThread clientThread)
 {
     clients.Remove(clientThread);
 }
コード例 #8
0
ファイル: Server.cs プロジェクト: kennyboy55/ErgometerIPR
        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);
            }
        }