aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/objective-c/examples/Sample/RouteGuideClient/RouteGuide.pbrpc.m
blob: 2ca3dc6768fb4f76e62e95c33f2a4bad857085c9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#import "RouteGuide.pbrpc.h"
#import <gRPC/GRXWriteable.h>
#import <gRPC/GRXWriter+Immediate.h>
#import <gRPC/ProtoRPC.h>

static NSString *const kPackageName = @"grpc.example.routeguide";
static NSString *const kServiceName = @"RouteGuide";

@implementation RGDRouteGuide

// Designated initializer
- (instancetype)initWithHost:(NSString *)host {
  return (self = [super initWithHost:host packageName:kPackageName serviceName:kServiceName]);
}

// Override superclass initializer to disallow different package and service names.
- (instancetype)initWithHost:(NSString *)host
                 packageName:(NSString *)packageName
                 serviceName:(NSString *)serviceName {
  return [self initWithHost:host];
}


#pragma mark GetFeature(Point) returns (Feature)

- (void)getFeatureWithRequest:(RGDPoint *)request handler:(void(^)(RGDFeature *response, NSError *error))handler{
  [[self RPCToGetFeatureWithRequest:request handler:handler] start];
}
// Returns a not-yet-started RPC object.
- (ProtoRPC *)RPCToGetFeatureWithRequest:(RGDPoint *)request handler:(void(^)(RGDFeature *response, NSError *error))handler{
  return [self RPCToMethod:@"GetFeature"
            requestsWriter:[GRXWriter writerWithValue:request]
             responseClass:[RGDFeature class]
        responsesWriteable:[GRXWriteable writeableWithSingleValueHandler:handler]];
}
#pragma mark ListFeatures(Rectangle) returns (stream Feature)

- (void)listFeaturesWithRequest:(RGDRectangle *)request handler:(void(^)(BOOL done, RGDFeature *response, NSError *error))handler{
  [[self RPCToListFeaturesWithRequest:request handler:handler] start];
}
// Returns a not-yet-started RPC object.
- (ProtoRPC *)RPCToListFeaturesWithRequest:(RGDRectangle *)request handler:(void(^)(BOOL done, RGDFeature *response, NSError *error))handler{
  return [self RPCToMethod:@"ListFeatures"
            requestsWriter:[GRXWriter writerWithValue:request]
             responseClass:[RGDFeature class]
        responsesWriteable:[GRXWriteable writeableWithStreamHandler:handler]];
}
#pragma mark RecordRoute(stream Point) returns (RouteSummary)

- (void)recordRouteWithRequestsWriter:(id<GRXWriter>)request handler:(void(^)(RGDRouteSummary *response, NSError *error))handler{
  [[self RPCToRecordRouteWithRequestsWriter:request handler:handler] start];
}
// Returns a not-yet-started RPC object.
- (ProtoRPC *)RPCToRecordRouteWithRequestsWriter:(id<GRXWriter>)request handler:(void(^)(RGDRouteSummary *response, NSError *error))handler{
  return [self RPCToMethod:@"RecordRoute"
            requestsWriter:request
             responseClass:[RGDRouteSummary class]
        responsesWriteable:[GRXWriteable writeableWithSingleValueHandler:handler]];
}
#pragma mark RouteChat(stream RouteNote) returns (stream RouteNote)

- (void)routeChatWithRequestsWriter:(id<GRXWriter>)request handler:(void(^)(BOOL done, RGDRouteNote *response, NSError *error))handler{
  [[self RPCToRouteChatWithRequestsWriter:request handler:handler] start];
}
// Returns a not-yet-started RPC object.
- (ProtoRPC *)RPCToRouteChatWithRequestsWriter:(id<GRXWriter>)request handler:(void(^)(BOOL done, RGDRouteNote *response, NSError *error))handler{
  return [self RPCToMethod:@"RouteChat"
            requestsWriter:request
             responseClass:[RGDRouteNote class]
        responsesWriteable:[GRXWriteable writeableWithStreamHandler:handler]];
}
@end