Exemplo n.º 1
0
        static void Main(string[] args)
        {
            var client = new RPCClient(new Client(), new JsonSerializer());

            client.OnConnected       += () => Console.WriteLine("Connected to server.");
            client.OnFailedToConnect += () => Console.WriteLine("FailedToConnect");
            client.OnDisconnected    += () => Console.WriteLine("Disconnected");
            client.Connect("localhost", 13);

            //client.OnRecieved += (bytes) => {
            //    var str = Encoding.ASCII.GetString(bytes);
            //    Console.WriteLine(str);
            //};

            client.On <LogDTO>(Log);
            client.On <LogDTO>(LogWarning);

            int i = 0;

            while (true)
            {
                Console.ReadKey();

                _sw.Restart();
                client.Ask <long>("Ping", Pong, DateTime.Now.Ticks);
                client.Send("Log", new LogDTO {
                    Message = "Console speaks! " + i++
                });
            }
        }