Esempio n. 1
0
        private void ReadAndSendDataHost()
        {
            var serverTag = new ServerTag();

            serverTag.ReadFromPacket(hostReader);
            MainClientServer.SendDataAboutHost(serverTag);
        }
Esempio n. 2
0
 public ClientServer(TcpClient tcpClient, MainClientServer mainClientServer)
 {
     client   = tcpClient;
     clientID = Guid.NewGuid().ToString();
     this.mainClientServer = mainClientServer;
     mainClientServer.AddConnectionClient(clientID, this);
 }
Esempio n. 3
0
        static void Main(string[] args)
        {
            try
            {
                serverHosts   = new MainHostServer();
                serverClients = new MainClientServer();
                Task.Factory.StartNew(serverClients.GettingClients, TaskCreationOptions.LongRunning);
                Task.Factory.StartNew(serverHosts.GettingHosts, TaskCreationOptions.LongRunning);

                while (true)
                {
                    Console.WriteLine("If you want to disconnect the main Server, press '7'!");
                    var key = Console.ReadKey(true);
                    if (key.KeyChar == '7')
                    {
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                serverHosts.DisconnectHosts();
                serverClients.DisconnectClients();
                Console.WriteLine(ex.Message);
            }
        }