Ejemplo n.º 1
0
        public void Start()
        {
            Console.WriteLine("Starting server...");

            IPAddress   ip       = IPAddress.Parse("192.168.8.107");
            TcpListener listener = new TcpListener(ip, 5000);

            listener.Start();
            Connection connection = new Connection();

            Console.WriteLine("Server started..");

            while (true)
            {
                TcpClient     client = listener.AcceptTcpClient();
                NetworkStream stream = client.GetStream();
                Console.Out.WriteLine("Client connected");

                ServerHandler communicationThreadHandler = new ServerHandler(stream, connection);
                connection.AddHandler(communicationThreadHandler);
                Thread thread = new Thread(communicationThreadHandler.Run);
                thread.Start();
            }
        }
Ejemplo n.º 2
0
 public void RemoveHandler(ServerHandler communicationThreadHandler)
 {
     connection.Remove(communicationThreadHandler);
 }
Ejemplo n.º 3
0
 public void AddHandler(ServerHandler communicationThreadHandler)
 {
     connection.Add(communicationThreadHandler);
 }