Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            var proxy      = NetRpcManager.CreateClientProxy <IService>(Helper.GetMQParam()).Proxy;
            var fileStream = File.Open(@"d:\4\1212.pdf", FileMode.Open, FileAccess.Read, FileShare.ReadWrite);

            for (int i = 0; i < 10; i++)
            {
                proxy.CallAsync(fileStream, j => Console.WriteLine(j), i.ToString());
                Console.WriteLine($"Send {i}");
            }

            Console.WriteLine($"Send end");
            Console.Read();
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            //RabbitMQ
            Console.WriteLine("---  [RabbitMQ]  ---");
            var mqF         = new ClientConnectionFactory(Helper.GetMQParam());
            var clientProxy = NetRpcManager.CreateClientProxy <IService>(mqF, false);

            clientProxy.Connected        += (s, e) => Console.WriteLine("[event] Connected");
            clientProxy.DisConnected     += (s, e) => Console.WriteLine("[event] DisConnected");
            clientProxy.ExceptionInvoked += (s, e) => Console.WriteLine("[event] ExceptionInvoked");

            //Heartbeat
            clientProxy.Heartbeat += async s =>
            {
                Console.WriteLine("[event] Heartbeat");
                s.Proxy.Hearbeat();
            };
            clientProxy.StartHeartbeat(true);

            _proxy      = clientProxy.Proxy;
            _proxyAsync = NetRpcManager.CreateClientProxy <IServiceAsync>(mqF, false).Proxy;
            RunTest();
            RunTestAsync().Wait();

            //Grpc
            Console.WriteLine("\r\n--- [Grpc]  ---");
            var grpcF = new NetRpc.Grpc.ClientConnectionFactory(new Channel("localhost", 50001, ChannelCredentials.Insecure));

            _proxy      = NetRpc.Grpc.NetRpcManager.CreateClientProxy <IService>(grpcF).Proxy;
            _proxyAsync = NetRpc.Grpc.NetRpcManager.CreateClientProxy <IServiceAsync>(grpcF).Proxy;
            RunTest();
            RunTestAsync().Wait();

            Console.WriteLine("Test end.");
            Console.Read();
        }