コード例 #1
0
        static void Main(string[] args)
        {
            client = new ChatClient(591, IPAddress.Parse("127.0.0.1"));
            string mode, message, name;

            client.PacketRecieved += ProcessPacket;
            client.Start();

            Console.WriteLine("--------------Client started--------------");
            Console.Write("Do you want to register (r) or to login (l): ");
            mode = Console.ReadLine();

            if (mode == "r")
            {
                Console.Write("Enter your name: ");
                name = Console.ReadLine();
                client.CurrentUser = new User(name, client.ClientPort, client.ClientIP);
                client.SendPacket(new RegistrationRequestPacket(client.CurrentUser));

                while (true)
                {
                    message = Console.ReadLine();

                    client.SendPacket(new MessagePacket(client.CurrentUser, message));
                }
            }
            else if (mode == "l")
            {
                //Implemention of logging system
            }
        }