aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples/objective-c/route_guide
diff options
context:
space:
mode:
authorGravatar Jorge Canizales <jcanizales@google.com>2015-10-28 05:51:11 -0700
committerGravatar Jorge Canizales <jcanizales@google.com>2015-10-28 05:51:11 -0700
commit8676d22b3d9ee2c69b50b360fa07a57d3753e82f (patch)
treeee5fee0e616c9d9c70d2df819a69692b3b038f87 /examples/objective-c/route_guide
parented2216b2c8d5e0dd3542ff573493bfffbdf9f11c (diff)
Fix RouteGuide example to use the last surface
Diffstat (limited to 'examples/objective-c/route_guide')
-rw-r--r--examples/objective-c/route_guide/ViewControllers.m28
1 files changed, 16 insertions, 12 deletions
diff --git a/examples/objective-c/route_guide/ViewControllers.m b/examples/objective-c/route_guide/ViewControllers.m
index cfc3338bca..8332661d57 100644
--- a/examples/objective-c/route_guide/ViewControllers.m
+++ b/examples/objective-c/route_guide/ViewControllers.m
@@ -36,7 +36,7 @@
#import <RxLibrary/GRXWriter+Immediate.h>
#import <RxLibrary/GRXWriter+Transformations.h>
-static NSString * const kHostAddress = @"http://localhost:50051";
+static NSString * const kHostAddress = @"localhost:50051";
// Category to override RTGPoint's description.
@interface RTGPoint (Description)
@@ -86,7 +86,10 @@ static NSString * const kHostAddress = @"http://localhost:50051";
- (void)viewDidLoad {
[super viewDidLoad];
- RTGRouteGuide *client = [[RTGRouteGuide alloc] initWithHost:kHostAddress];
+ // This only needs to be done once per host, before creating service objects for that host.
+ [GRPCCall useInsecureConnectionsForHost:kHostAddress];
+
+ RTGRouteGuide *service = [RTGRouteGuide serviceWithHost:kHostAddress];
void (^handler)(RTGFeature *response, NSError *error) = ^(RTGFeature *response, NSError *error) {
if (response.name.length) {
@@ -102,8 +105,8 @@ static NSString * const kHostAddress = @"http://localhost:50051";
point.latitude = 409146138;
point.longitude = -746188906;
- [client getFeatureWithRequest:point handler:handler];
- [client getFeatureWithRequest:[RTGPoint message] handler:handler];
+ [service getFeatureWithRequest:point handler:handler];
+ [service getFeatureWithRequest:[RTGPoint message] handler:handler];
}
@end
@@ -122,7 +125,7 @@ static NSString * const kHostAddress = @"http://localhost:50051";
- (void)viewDidLoad {
[super viewDidLoad];
- RTGRouteGuide *client = [[RTGRouteGuide alloc] initWithHost:kHostAddress];
+ RTGRouteGuide *service = [RTGRouteGuide serviceWithHost:kHostAddress];
RTGRectangle *rectangle = [RTGRectangle message];
rectangle.lo.latitude = 405E6;
@@ -131,8 +134,8 @@ static NSString * const kHostAddress = @"http://localhost:50051";
rectangle.hi.longitude = -745E6;
NSLog(@"Looking for features between %@ and %@", rectangle.lo, rectangle.hi);
- [client listFeaturesWithRequest:rectangle
- eventHandler:^(BOOL done, RTGFeature *response, NSError *error) {
+ [service listFeaturesWithRequest:rectangle
+ eventHandler:^(BOOL done, RTGFeature *response, NSError *error) {
if (response) {
NSLog(@"Found feature at %@ called %@.", response.location, response.name);
} else if (error) {
@@ -171,9 +174,10 @@ static NSString * const kHostAddress = @"http://localhost:50051";
return location;
}];
- RTGRouteGuide *client = [[RTGRouteGuide alloc] initWithHost:kHostAddress];
+ RTGRouteGuide *service = [RTGRouteGuide serviceWithHost:kHostAddress];
- [client recordRouteWithRequestsWriter:locations handler:^(RTGRouteSummary *response, NSError *error) {
+ [service recordRouteWithRequestsWriter:locations
+ handler:^(RTGRouteSummary *response, NSError *error) {
if (response) {
NSLog(@"Finished trip with %i points", response.pointCount);
NSLog(@"Passed %i features", response.featureCount);
@@ -210,10 +214,10 @@ static NSString * const kHostAddress = @"http://localhost:50051";
return note;
}];
- RTGRouteGuide *client = [[RTGRouteGuide alloc] initWithHost:kHostAddress];
+ RTGRouteGuide *service = [RTGRouteGuide serviceWithHost:kHostAddress];
- [client routeChatWithRequestsWriter:notesWriter
- eventHandler:^(BOOL done, RTGRouteNote *note, NSError *error) {
+ [service routeChatWithRequestsWriter:notesWriter
+ eventHandler:^(BOOL done, RTGRouteNote *note, NSError *error) {
if (note) {
NSLog(@"Got message %@ at %@", note.message, note.location);
} else if (error) {