aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/objective-c/ProtoRPC/ProtoRPC.m
diff options
context:
space:
mode:
authorGravatar Jorge Canizales <jcanizales@google.com>2015-04-21 01:30:00 -0700
committerGravatar Jorge Canizales <jcanizales@google.com>2015-04-22 11:35:20 -0700
commit6482d5dc90267144f11ccd63fdd8e4f3fbcf6d8b (patch)
treeca67cecd7200933c90ad712d85cd801253a62d4b /src/objective-c/ProtoRPC/ProtoRPC.m
parent2779ccb83cf1f42e8aa7330640e6086f804f54cd (diff)
Makes the runtime serialize alright.
Diffstat (limited to 'src/objective-c/ProtoRPC/ProtoRPC.m')
-rw-r--r--src/objective-c/ProtoRPC/ProtoRPC.m12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/objective-c/ProtoRPC/ProtoRPC.m b/src/objective-c/ProtoRPC/ProtoRPC.m
index 1b046845ce..4a2372e240 100644
--- a/src/objective-c/ProtoRPC/ProtoRPC.m
+++ b/src/objective-c/ProtoRPC/ProtoRPC.m
@@ -33,7 +33,10 @@
#import "ProtoRPC.h"
+#import <ProtocolBuffers/ProtocolBuffers.h>
#import <RxLibrary/GRXWriteable.h>
+#import <RxLibrary/GRXWriter.h>
+#import <RxLibrary/GRXWriter+Transformations.h>
@implementation ProtoRPC {
id<GRXWriteable> _responseWriteable;
@@ -60,7 +63,13 @@
[NSException raise:NSInvalidArgumentException
format:@"A protobuf class to parse the responses must be provided."];
}
- if ((self = [super initWithHost:host method:method requestsWriter:requestsWriter])) {
+ // A writer that serializes the proto messages to send.
+ id<GRXWriter> bytesWriter =
+ [[[GRXWriter alloc] initWithWriter:requestsWriter] map:^id(PBGeneratedMessage *proto) {
+ return [proto data];
+ }];
+ if ((self = [super initWithHost:host method:method requestsWriter:bytesWriter])) {
+ // A writeable that parses the proto messages received.
_responseWriteable = [[GRXWriteable alloc] initWithValueHandler:^(NSData *value) {
[responsesWriteable didReceiveValue:[responseClass parseFromData:value]];
} completionHandler:^(NSError *errorOrNil) {
@@ -76,6 +85,7 @@
- (void)startWithWriteable:(id<GRXWriteable>)writeable {
[super startWithWriteable:writeable];
+ // Break retain cycles.
_responseWriteable = nil;
}
@end