From da5452578a118ddcc8833be5baa36616846b449a Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 25 Jul 2018 18:54:03 +0200 Subject: experimental helloworld client for ios --- .../csharp/HelloworldXamarin/iOS/ViewController.cs | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'examples/csharp') diff --git a/examples/csharp/HelloworldXamarin/iOS/ViewController.cs b/examples/csharp/HelloworldXamarin/iOS/ViewController.cs index dfbaf084b6..33bb4a00e2 100644 --- a/examples/csharp/HelloworldXamarin/iOS/ViewController.cs +++ b/examples/csharp/HelloworldXamarin/iOS/ViewController.cs @@ -1,4 +1,6 @@ using System; +using Grpc.Core; +using Helloworld; using UIKit; @@ -19,8 +21,8 @@ namespace HelloworldXamarin.iOS // Perform any additional setup after loading the view, typically from a nib. Button.AccessibilityIdentifier = "myButton"; Button.TouchUpInside += delegate - { - var title = string.Format("{0} clicks!", count++); + { + var title = SayHello(); Button.SetTitle(title, UIControlState.Normal); }; } @@ -30,5 +32,21 @@ namespace HelloworldXamarin.iOS base.DidReceiveMemoryWarning(); // Release any cached data, images, etc that aren't in use. } + + private string SayHello() + { + + // use loopback on host machine: https://developer.android.com/studio/run/emulator-networking + Channel channel = new Channel("10.0.2.2:50051", ChannelCredentials.Insecure); + + var client = new Greeter.GreeterClient(channel); + string user = "Xamarin"; + + var reply = client.SayHello(new HelloRequest { Name = user }); + + channel.ShutdownAsync().Wait(); + + return "Greeting: " + reply.Message; + } } } -- cgit v1.2.3