Exemplo n.º 1
0
        static void Main(string[] args)
        {
            DefaultClientPacket packet = new DefaultClientPacket();

            packet.Register(typeof(Employee).Assembly);
            TcpClient client = SocketFactory.CreateClient <TcpClient>(packet, "127.0.0.1", 9090);

            //TcpClient client = SocketFactory.CreateClient<TcpClient>(packet, "127.0.0.1", 9090,"localhost");
            while (true)
            {
                Console.Write("enter get employee quantity:");
                string line = Console.ReadLine();
                int    quantity;
                if (int.TryParse(line, out quantity))
                {
                    SearchEmployee search = new SearchEmployee();
                    search.Quantity = quantity;
                    client.SendMessage(search);
                    var result = client.ReadMessage <IList <Employee> >();
                    foreach (Employee item in result)
                    {
                        Console.WriteLine("\t{0} {1}", item.FirstName, item.LastName);
                    }
                }
                else
                {
                    Console.WriteLine("input not a number!");
                }
            }
        }
Exemplo n.º 2
0
        public static void Main(string[] args)
        {
            SearchEmployee search;

            DefaultClientPacket.Register(typeof(Program));
            IClient client = ServerFactory.CreateTcpClient <DefaultClientPacket>("127.0.0.1", 9090);

            client.Packet.Completed = OnReceive;
            client.ClientError      = (c, e, m) =>
            {
                Console.WriteLine(m);
            };
            search      = new SearchEmployee();
            search.Size = 1;
            client.Send(search);
            Console.Read();
        }