Skip to content
Snippets Groups Projects
Commit 05456f81 authored by Jorge Canizales's avatar Jorge Canizales
Browse files

Move sample app to proto3 and clarify usage example

parent c54a0caa
No related branches found
No related tags found
No related merge requests found
......@@ -37,7 +37,8 @@
#import <gRPC/GRPCMethodName.h>
#import <gRPC/GRXWriter+Immediate.h>
#import <gRPC/GRXWriteable.h>
#import <RemoteTest/Messages.pb.h>
#import <RemoteTest/Messages.pbobjc.h>
#import <RemoteTest/Test.pbrpc.h>
@interface ViewController ()
@end
......@@ -47,18 +48,34 @@
- (void)viewDidLoad {
[super viewDidLoad];
NSString * const kRemoteHost = @"grpc-test.sandbox.google.com";
RMTSimpleRequest *request = [[RMTSimpleRequest alloc] init];
request.responseSize = 10;
request.fillUsername = YES;
request.fillOauthScope = YES;
// Example gRPC call using a generated proto client library:
RMTTestService *service = [[RMTTestService alloc] initWithHost:kRemoteHost];
[service unaryCallWithRequest:request handler:^(RMTSimpleResponse *response, NSError *error) {
if (response) {
NSLog(@"Finished successfully with response:\n%@", response);
} else if (error) {
NSLog(@"Finished with error: %@", error);
}
}];
// Same example call using the generic gRPC client library:
GRPCMethodName *method = [[GRPCMethodName alloc] initWithPackage:@"grpc.testing"
interface:@"TestService"
method:@"UnaryCall"];
RMTSimpleRequest *request = [[[[[[RMTSimpleRequestBuilder alloc] init]
setResponseSize:100]
setFillUsername:YES]
setFillOauthScope:YES]
build];
id<GRXWriter> requestsWriter = [GRXWriter writerWithValue:[request data]];
GRPCCall *call = [[GRPCCall alloc] initWithHost:@"grpc-test.sandbox.google.com"
GRPCCall *call = [[GRPCCall alloc] initWithHost:kRemoteHost
method:method
requestsWriter:requestsWriter];
......@@ -66,7 +83,11 @@
RMTSimpleResponse *response = [RMTSimpleResponse parseFromData:value];
NSLog(@"Received response:\n%@", response);
} completionHandler:^(NSError *errorOrNil) {
NSLog(@"Finished with error: %@", errorOrNil);
if (errorOrNil) {
NSLog(@"Finished with error: %@", errorOrNil);
} else {
NSLog(@"Finished successfully.");
}
}];
[call startWithWriteable:responsesWriteable];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment