aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples/csharp/HelloworldXamarin/iOS
diff options
context:
space:
mode:
authorGravatar Jan Tattermusch <jtattermusch@google.com>2018-07-25 18:54:03 +0200
committerGravatar Jan Tattermusch <jtattermusch@google.com>2018-07-31 12:42:47 +0200
commitda5452578a118ddcc8833be5baa36616846b449a (patch)
tree87a410d29226de121e9d1e2c866581dbcfd53d3f /examples/csharp/HelloworldXamarin/iOS
parent705843c041f24ce5b2737fc15dfd45c34f26cf82 (diff)
experimental helloworld client for ios
Diffstat (limited to 'examples/csharp/HelloworldXamarin/iOS')
-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;
+ }
}
}