Example #1
0
        public void Start()
        {
            Console.WriteLine("Enter your name");
            string Name = Console.ReadLine();

            Console.Title = $"{Name}";
            User user = new User(Name);

            user.ipAddress = IPAddress.Parse(GetIp());
            char choice;
            // Console.WriteLine(user.ToString());



            NetworkHost networkHost = new NetworkHost(user);

            // Console.WriteLine("Enter your choice");

            //bool flag = true;
            //  networkHost.StartListening();
            Console.WriteLine("Do you want to connect (Y/N) ?");
            choice = Char.Parse(Console.ReadLine());
            switch (choice)
            {
            case 'N':
                networkHost.StartListening();
                break;

            case 'Y':
                Console.WriteLine("Whom do you want to connect?(username@ip)");
                string userDetails = Console.ReadLine();
                user.peerName = userDetails.Split("@")[0];
                networkHost.Connect(userDetails.Split("@")[1]);
                break;
            }

            Console.ReadKey();
        }