aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--examples/csharp/HelloworldXamarin/iOS/ViewController.cs22
1 files changed, 20 insertions, 2 deletions
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;
+ }
}
}