Ejemplo n.º 1
0
        public PythonBackend(string serverAddress = null)
        {
            if (serverAddress is null)
            {
                serverAddress = Environment.GetEnvironmentVariable("PYTHON_BACKEND_ADDR");
            }

            _channel = new Channel(serverAddress, ChannelCredentials.Insecure);
            Client = new CalcService.CalcServiceClient(_channel);
        }
Ejemplo n.º 2
0
        public static void DoSimpleCalc(CalcService.CalcServiceClient client, int number1, int number2)
        {
            var calcRequest = new CalcRequest()
            {
                Number1 = number1,
                Number2 = number2
            };

            var response = client.Calc(calcRequest);

            Console.WriteLine(response.Result);
        }
Ejemplo n.º 3
0
        public async static Task Process()
        {
            Channel channel = new Channel("localhost", 50051, ChannelCredentials.Insecure);

            await channel.ConnectAsync().ContinueWith((task) =>
            {
                if (task.Status == TaskStatus.RanToCompletion)
                {
                    Console.WriteLine("The client connected successfully");
                }
            });

            var client = new CalcService.CalcServiceClient(channel);

            DoSimpleCalc(client, 2, 3);

            channel.ShutdownAsync().Wait();
        }