コード例 #1
0
        Program()
        {
            IPAddress ip = Info.GetIp();
            TcpListener listener = new TcpListener(ip,Info.Port);
            storage = new DataStorage();
            listener.Start();
            int counter = 0;
            Console.WriteLine("Server started: {0}",DateTime.Now);
            Console.WriteLine("Server ip: {0}", ip);
            Console.WriteLine("Server port: {0}",Info.Port);

            while (true)
            {
                TcpClient newClient = listener.AcceptTcpClient();
                if (!IsMonitor(newClient))
                {
                    counter++;
                    Console.WriteLine("is client");
                    Client client = new Client(newClient, this, counter, storage);
                    clients.Add(client);
                }
                else if (_monitor != null)
                {
                    if (!_monitor.TcpClient.Connected)
                    {
                        _monitor = new Monitor(newClient,this,clients, storage);
                    }
                }
                else
                {
                    _monitor = new Monitor(newClient,this,clients, storage);
                }
            }
        }
コード例 #2
0
 public Client(TcpClient tcpClient, Program server, int number, DataStorage storage) : base(tcpClient, server)
 {
     this._storage = storage;
     identifier    = new Identifier("", number);
 }
コード例 #3
0
 public Monitor(TcpClient client, Program server, List<Client> clients, DataStorage storage)
     : base(client, server)
 {
     this._storage = storage;
     this._clients = clients;
 }