Adds basic runtime library and generated stub

The stub is manually adapted:

- to the evolved runtime,
- as if generated with insertion points.
pull/1354/head
Jorge Canizales 10 years ago
parent 2c48566e71
commit 2779ccb83c
  1. 18
      ProtoRPC.podspec
  2. 3
      src/objective-c/GRPCClient/GRPCMethodName.h
  3. 46
      src/objective-c/ProtoRPC/ProtoRPC.h
  4. 81
      src/objective-c/ProtoRPC/ProtoRPC.m
  5. 49
      src/objective-c/ProtoRPC/ProtoService.h
  6. 81
      src/objective-c/ProtoRPC/ProtoService.m
  7. 6
      src/objective-c/RxLibrary/GRXWriteable.h
  8. 24
      src/objective-c/RxLibrary/GRXWriteable.m
  9. 1
      src/objective-c/examples/Sample/Podfile
  10. 1
      src/objective-c/examples/Sample/RemoteTestClient/RemoteTest.podspec
  11. 85
      src/objective-c/examples/Sample/RemoteTestClient/Test.pb.h
  12. 128
      src/objective-c/examples/Sample/RemoteTestClient/Test.pb.m

@ -0,0 +1,18 @@
Pod::Spec.new do |s|
s.name = 'ProtoRPC'
s.version = '0.0.1'
s.summary = 'RPC library for ProtocolBuffers, based on gRPC'
s.homepage = 'https://github.com/grpc/grpc/tree/master/src/objective-c/ProtoRPC'
s.license = 'New BSD'
s.authors = { 'Jorge Canizales' => 'jcanizales@google.com' }
# s.source = { :git => 'https://github.com/grpc/grpc.git', :tag => 'release-0_5_0' }
s.source_files = 'src/objective-c/ProtoRPC/*.{h,m}'
s.platform = :ios
s.ios.deployment_target = '6.0'
s.requires_arc = true
s.dependency 'gRPC', '~> 0.0'
s.dependency 'RxLibrary', '~> 0.0'
end

@ -37,7 +37,8 @@
// A fully-qualified gRPC method name. Full qualification is needed because a gRPC endpoint can
// implement multiple interfaces.
// TODO(jcanizales): Is this proto-specific, or actual part of gRPC? If the former, move one layer up.
// TODO(jcanizales): Move to ProtoRPC package.
// TODO(jcanizales): Rename interface -> service.
@interface GRPCMethodName : NSObject
@property(nonatomic, readonly) NSString *package;
@property(nonatomic, readonly) NSString *interface;

@ -0,0 +1,46 @@
/*
*
* Copyright 2015, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#import <Foundation/Foundation.h>
#import <gRPC/GRPCCall.h>
@interface ProtoRPC : GRPCCall
- (instancetype)initWithHost:(NSString *)host
method:(GRPCMethodName *)method
requestsWriter:(id<GRXWriter>)requestsWriter
responseClass:(Class)responseClass
responsesWriteable:(id<GRXWriteable>)responsesWriteable NS_DESIGNATED_INITIALIZER;
- (void)start;
@end

@ -0,0 +1,81 @@
/*
*
* Copyright 2015, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#import "ProtoRPC.h"
#import <RxLibrary/GRXWriteable.h>
@implementation ProtoRPC {
id<GRXWriteable> _responseWriteable;
}
- (instancetype)initWithHost:(NSString *)host
method:(GRPCMethodName *)method
requestsWriter:(id<GRXWriter>)requestWriter {
return [self initWithHost:host
method:method
requestsWriter:requestsWriter
responseClass:nil
responsesWriteable:nil];
}
// Designated initializer
- (instancetype)initWithHost:(NSString *)host
method:(GRPCMethodName *)method
requestsWriter:(id<GRXWriter>)requestsWriter
responseClass:(Class)responseClass
responsesWriteable:(id<GRXWriteable>)responsesWriteable {
// Because we can't tell the type system to constrain the class, we need to check at runtime:
if (![class respondsToSelector:@selector(parseFromData:)]) {
[NSException raise:NSInvalidArgumentException
format:@"A protobuf class to parse the responses must be provided."];
}
if ((self = [super initWithHost:host method:method requestsWriter:requestsWriter])) {
_responseWriteable = [[GRXWriteable alloc] initWithValueHandler:^(NSData *value) {
[responsesWriteable didReceiveValue:[responseClass parseFromData:value]];
} completionHandler:^(NSError *errorOrNil) {
[responsesWriteable didFinishWithError:errorOrNil];
}];
}
return self;
}
- (void)start {
[self startWithWriteable:_responseWriteable];
}
- (void)startWithWriteable:(id<GRXWriteable>)writeable {
[super startWithWriteable:writeable];
_responseWriteable = nil;
}
@end

@ -0,0 +1,49 @@
/*
*
* Copyright 2015, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#import <Foundation/Foundation.h>
@class ProtoRPC;
@protocol GRXWriteable;
@protocol GRXWriter;
@interface ProtoService : NSObject
- (instancetype)initWithHost:(NSString *)host
packageName:(NSString *)packageName
serviceName:(NSString *)serviceName NS_DESIGNATED_INITIALIZER;
- (ProtoRPC *)RPCToMethod:(NSString *)method
requestsWriter:(id<GRXWriter>)requestsWriter
responseClass:(Class)responseClass
responsesWriteable:(id<GRXWriteable>)responsesWriteable;
@end

@ -0,0 +1,81 @@
/*
*
* Copyright 2015, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#import "ProtoService.h"
#import <gRPC/GRPCMethodName.h>
#import <RxLibrary/GRXWriteable.h>
#import <RxLibrary/GRXWriter.h>
#import "ProtoRPC.h"
@implementation ProtoService {
NSString *_host;
NSString *_packageName;
NSString *_serviceName;
}
- (instancetype)init {
return [self initWithHost:nil];
}
// Designated initializer
- (instancetype)initWithHost:(NSString *)host
packageName:(NSString *)packageName
serviceName:(NSString *)serviceName {
if (!host || !serviceName) {
[NSException raise:NSInvalidArgumentException
format:@"Neither host nor serviceName can be nil."];
}
if ((self = [super init])) {
_host = [host copy];
_packageName = [packageName copy];
_serviceName = [serviceName copy];
}
return self;
}
- (ProtoRPC *)RPCToMethod:(NSString *)method
requestsWriter:(id<GRXWriter>)requestsWriter
responseClass:(Class)responseClass
responsesWriteable:(id<GRXWriteable>)responsesWriteable {
GRPCMethodName *methodName = [[GRPCMethodName alloc] initWithPackage:_packageName
interface:_serviceName
method:_method];
return [[ProtoRPC alloc] initWithHost:_host
method:methodName
requestsWriter:requestsWriter
responseClass:responseClass
responsesWriteable:responsesWriteable];
}
@end

@ -50,10 +50,16 @@
typedef void (^GRXValueHandler)(id value);
typedef void (^GRXCompletionHandler)(NSError *errorOrNil);
typedef void (^GRXSingleValueHandler)(id value, NSError *errorOrNil);
typedef void (^GRXStreamHandler)(BOOL done, id value, NSError *error);
// Utility to create objects that conform to the GRXWriteable protocol, from
// blocks that handle each of the two methods of the protocol.
@interface GRXWriteable : NSObject<GRXWriteable>
+ (instancetype)writeableWithSingleValueHandler:(GRXSingleValueHandler)handler;
+ (instancetype)writeableWithStreamHandler:(GRXStreamHandler)handler;
- (instancetype)initWithValueHandler:(GRXValueHandler)valueHandler
completionHandler:(GRXCompletionHandler)completionHandler
NS_DESIGNATED_INITIALIZER;

@ -38,6 +38,30 @@
GRXCompletionHandler _completionHandler;
}
+ (instancetype)writeableWithSingleValueHandler:(GRXSingleValueHandler)handler {
if (!handler) {
return [[self alloc] init];
}
return [[self alloc] initWithValueHandler:^(id value) {
handler(value, nil);
} completionHandler:^(NSError *errorOrNil) {
if (errorOrNil) {
handler(nil, errorOrNil);
}
}];
}
+ (instancetype)writeableWithStreamHandler:(GRXStreamHandler)handler {
if (!handler) {
return [[self alloc] init];
}
return [[self alloc] initWithValueHandler:^(id value) {
handler(NO, value, nil);
} completionHandler:^(NSError *errorOrNil) {
handler(YES, nil, errorOrNil);
}];
}
- (instancetype)init {
return [self initWithValueHandler:nil completionHandler:nil];
}

@ -2,6 +2,7 @@ source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
pod 'gRPC', :path => "../../../.."
pod 'ProtoRPC', :path => "../../../.."
pod 'Route_guide', :path => "RouteGuideClient"
pod 'RemoteTest', :path => "RemoteTestClient"

@ -14,4 +14,5 @@ Pod::Spec.new do |s|
s.requires_arc = true
s.dependency 'ProtocolBuffers', '~> 1.9'
s.dependency 'ProtoRPC', '~> 0.0'
end

@ -4,6 +4,7 @@
#import "Empty.pb.h"
#import "Messages.pb.h"
#import <ProtoRPC/ProtoService.h>
// @@protoc_insertion_point(imports)
@class ObjectiveCFileOptions;
@ -78,4 +79,88 @@
@end
@protocol GRXWriteable;
@protocol GRXWriter;
@protocol RMTTestService <NSObject>
#pragma mark EmptyCall(grpc.testing.Empty) returns (grpc.testing.Empty)
// One empty request followed by one empty response.
- (void)emptyCallWithRequest:(RMTEmpty *)request
handler:(void(^)(RMTEmpty *response, NSError *error))handler;
// Returns a not-yet-started RPC object.
- (ProtoRPC *)RPCToEmptyCallWithRequest:(RMTEmpty *)request
handler:(void(^)(RMTEmpty *response, NSError *error))handler;
#pragma mark UnaryCall(SimpleRequest) returns (SimpleResponse)
// One request followed by one response.
- (void)unaryCallWithRequest:(RMTSimpleRequest *)request
handler:(void(^)(RMTSimpleResponse *response, NSError *error))handler;
// Returns a not-yet-started RPC object.
- (ProtoRPC *)RPCToUnaryCallWithRequest:(RMTSimpleRequest *)request
handler:(void(^)(RMTSimpleResponse *response, NSError *error))handler;
#pragma mark StreamingOutputCall(StreamingOutputCallRequest) returns (stream StreamingOutputCallResponse)
// One request followed by a sequence of responses (streamed download).
// The server returns the payload with client desired type and sizes.
- (void)streamingOutputCallWithRequest:(RMTStreamingOutputCallRequest *)request
handler:(void(^)(BOOL done, RMTStreamingOutputCallResponse *response, NSError *error))handler;
// Returns a not-yet-started RPC object.
- (ProtoRPC *)RPCToStreamingOutputCallWithRequest:(RMTStreamingOutputCallRequest *)request
handler:(void(^)(BOOL done, RMTStreamingOutputCallResponse *response, NSError *error))handler;
#pragma mark StreamingInputCall(stream StreamingInputCallRequest) returns (StreamingInputCallResponse)
// A sequence of requests followed by one response (streamed upload).
// The server returns the aggregated size of client payload as the result.
- (void)streamingInputCallWithRequestsWriter:(id<GRXWriter>)request
handler:(void(^)(RMTStreamingInputCallResponse *response, NSError *error))handler;
// Returns a not-yet-started RPC object.
- (ProtoRPC *)RPCToStreamingInputCallWithRequestsWriter:(id<GRXWriter>)request
handler:(void(^)(RMTStreamingInputCallResponse *response, NSError *error))handler;
#pragma mark FullDuplexCall(stream StreamingOutputCallRequest) returns (stream StreamingOutputCallResponse)
// A sequence of requests with each request served by the server immediately.
// As one request could lead to multiple responses, this interface
// demonstrates the idea of full duplexing.
- (void)fullDuplexCallWithRequestsWriter:(id<GRXWriter>)request
handler:(void(^)(BOOL done, RMTStreamingOutputCallResponse *response, NSError *error))handler;
// Returns a not-yet-started RPC object.
- (ProtoRPC *)RPCToFullDuplexCallWithRequestsWriter:(id<GRXWriter>)request
handler:(void(^)(BOOL done, RMTStreamingOutputCallResponse *response, NSError *error))handler;
#pragma mark HalfDuplexCall(stream StreamingOutputCallRequest) returns (stream StreamingOutputCallResponse)
// A sequence of requests followed by a sequence of responses.
// The server buffers all the client requests and then serves them in order. A
// stream of responses are returned to the client when the server starts with
// first request.
- (void)halfDuplexCallWithRequestsWriter:(id<GRXWriter>)request
handler:(void(^)(BOOL done, RMTStreamingOutputCallResponse *response, NSError *error))handler;
// Returns a not-yet-started RPC object.
- (ProtoRPC *)RPCToHalfDuplexCallWithRequestsWriter:(id<GRXWriter>)request
handler:(void(^)(BOOL done, RMTStreamingOutputCallResponse *response, NSError *error))handler;
@end
// Basic service implementation, over gRPC, that only does marshalling and parsing.
@interface RMTTestService : ProtoService<RMTTestService>
@end
// @@protoc_insertion_point(global_scope)

@ -1,6 +1,9 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
#import "Test.pb.h"
#import <RxLibrary/GRXWriteable.h>
#import <RxLibrary/GRXWriter+Immediate.h>
// @@protoc_insertion_point(imports)
@implementation RMTTestRoot
@ -24,4 +27,129 @@ static PBExtensionRegistry* extensionRegistry = nil;
@end
static NSString *const kServiceName = @"grpc.testing.TestService";
@implementation RMTTestService
- (instancetype)initWithHost:(NSString *)host {
return (self = [super initWithHost:host serviceName:kServiceName]);
}
#pragma mark EmptyCall(grpc.testing.Empty) returns (grpc.testing.Empty)
// One empty request followed by one empty response.
- (void)emptyCallWithRequest:(RMTEmpty *)request
handler:(void(^)(RMTEmpty *response, NSError *error))handler {
[[self RPCToEmptyCallWithRequest:request handler:handler] start];
}
// Returns a not-yet-started RPC object.
- (ProtoRPC *)RPCToEmptyCallWithRequest:(RMTEmpty *)request
handler:(void(^)(RMTEmpty *response, NSError *error))handler {
return [self RPCToMethod:@"EmptyCall"
requestsWriter:[GRXWriter writerWithValue:request];
responseClass:[RMTEmpty class]
responsesWriteable:[GRXWriteable writeableWithSingleValueHandler:handler]];
}
#pragma mark UnaryCall(SimpleRequest) returns (SimpleResponse)
// One request followed by one response.
- (void)unaryCallWithRequest:(RMTSimpleRequest *)request
handler:(void(^)(RMTSimpleResponse *response, NSError *error))handler {
[[self RPCToUnaryCallWithRequest:request handler:handler] start];
}
// Returns a not-yet-started RPC object.
- (ProtoRPC *)RPCToUnaryCallWithRequest:(RMTSimpleRequest *)request
handler:(void(^)(RMTSimpleResponse *response, NSError *error))handler {
return [self RPCToMethod:@"UnaryCall"
requestsWriter:[GRXWriter writerWithValue:request];
responseClass:[RMTSimpleResponse class]
responsesWriteable:[GRXWriteable writeableWithSingleValueHandler:handler]];
}
#pragma mark StreamingOutputCall(StreamingOutputCallRequest) returns (stream StreamingOutputCallResponse)
// One request followed by a sequence of responses (streamed download).
// The server returns the payload with client desired type and sizes.
- (void)streamingOutputCallWithRequest:(RMTStreamingOutputCallRequest *)request
handler:(void(^)(BOOL done, RMTStreamingOutputCallResponse *response, NSError *error))handler {
[[self RPCToStreamingOutputCallWithRequest:request handler:handler] start];
}
// Returns a not-yet-started RPC object.
- (ProtoRPC *)RPCToStreamingOutputCallWithRequest:(RMTStreamingOutputCallRequest *)request
handler:(void(^)(BOOL done, RMTStreamingOutputCallResponse *response, NSError *error))handler {
return [self RPCToMethod:@"StreamingOutputCall"
requestsWriter:[GRXWriter writerWithValue:request];
responseClass:[RMTStreamingOutputCallResponse class]
responsesWriteable:[GRXWriteable writeableWithStreamHandler:handler]];
}
#pragma mark StreamingInputCall(stream StreamingInputCallRequest) returns (StreamingInputCallResponse)
// A sequence of requests followed by one response (streamed upload).
// The server returns the aggregated size of client payload as the result.
- (void)streamingInputCallWithRequestsWriter:(id<GRXWriter>)requestsWriter
handler:(void(^)(RMTStreamingInputCallResponse *response, NSError *error))handler {
[[self RPCToStreamingInputCallWithRequestsWriter:requestsWriter handler:handler] start];
}
// Returns a not-yet-started RPC object.
- (ProtoRPC *)RPCToStreamingInputCallWithRequestsWriter:(id<GRXWriter>)requestsWriter
handler:(void(^)(RMTStreamingInputCallResponse *response, NSError *error))handler {
return [self RPCToMethod:@"StreamingInputCall"
requestsWriter:requestsWriter;
responseClass:[RMTStreamingInputCallResponse class]
responsesWriteable:[GRXWriteable writeableWithSingleValueHandler:handler]];
}
#pragma mark FullDuplexCall(stream StreamingOutputCallRequest) returns (stream StreamingOutputCallResponse)
// A sequence of requests with each request served by the server immediately.
// As one request could lead to multiple responses, this interface
// demonstrates the idea of full duplexing.
- (void)fullDuplexCallWithRequestsWriter:(id<GRXWriter>)requestsWriter
handler:(void(^)(BOOL done, RMTStreamingOutputCallResponse *response, NSError *error))handler {
[[self RPCToFullDuplexCallWithRequestsWriter:requestsWriter handler:handler] start];
}
// Returns a not-yet-started RPC object.
- (ProtoRPC *)RPCToFullDuplexCallWithRequestsWriter:(id<GRXWriter>)requestsWriter
handler:(void(^)(BOOL done, RMTStreamingOutputCallResponse *response, NSError *error))handler {
return [self RPCToMethod:@"FullDuplexCall"
requestsWriter:requestsWriter;
responseClass:[RMTStreamingOutputCallResponse class]
responsesWriteable:[GRXWriteable writeableWithStreamHandler:handler]];
}
#pragma mark HalfDuplexCall(stream StreamingOutputCallRequest) returns (stream StreamingOutputCallResponse)
// A sequence of requests followed by a sequence of responses.
// The server buffers all the client requests and then serves them in order. A
// stream of responses are returned to the client when the server starts with
// first request.
- (void)halfDuplexCallWithRequestsWriter:(id<GRXWriter>)requestsWriter
handler:(void(^)(BOOL done, RMTStreamingOutputCallResponse *response, NSError *error))handler {
[[self RPCToHalfDuplexCallWithRequestsWriter:requestsWriter handler:handler] start];
}
// Returns a not-yet-started RPC object.
- (ProtoRPC *)RPCToHalfDuplexCallWithRequestsWriter:(id<GRXWriter>)requestsWriter
handler:(void(^)(BOOL done, RMTStreamingOutputCallResponse *response, NSError *error))handler {
return [self RPCToMethod:@"HalfDuplexCall"
requestsWriter:requestsWriter;
responseClass:[RMTStreamingOutputCallResponse class]
responsesWriteable:[GRXWriteable writeableWithStreamHandler:handler]];
}
@end
// @@protoc_insertion_point(global_scope)

Loading…
Cancel
Save