• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 *
3 * Copyright 2015 gRPC authors.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 *     http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 */
18
19#import "ProtoService.h"
20
21#import <RxLibrary/GRXWriteable.h>
22#import <RxLibrary/GRXWriter.h>
23
24#import "ProtoMethod.h"
25#import "ProtoRPC.h"
26
27#pragma clang diagnostic push
28#pragma clang diagnostic ignored "-Wdeprecated-implementations"
29@implementation ProtoService {
30#pragma clang diagnostic pop
31  NSString *_host;
32  NSString *_packageName;
33  NSString *_serviceName;
34}
35
36- (instancetype)init {
37  return [self initWithHost:nil packageName:nil serviceName:nil];
38}
39
40// Designated initializer
41- (instancetype)initWithHost:(NSString *)host
42                 packageName:(NSString *)packageName
43                 serviceName:(NSString *)serviceName {
44  if (!host || !serviceName) {
45    [NSException raise:NSInvalidArgumentException
46                format:@"Neither host nor serviceName can be nil."];
47  }
48  if ((self = [super init])) {
49    _host = [host copy];
50    _packageName = [packageName copy];
51    _serviceName = [serviceName copy];
52  }
53  return self;
54}
55
56- (GRPCProtoCall *)RPCToMethod:(NSString *)method
57                requestsWriter:(GRXWriter *)requestsWriter
58                 responseClass:(Class)responseClass
59            responsesWriteable:(id<GRXWriteable>)responsesWriteable {
60  GRPCProtoMethod *methodName =
61      [[GRPCProtoMethod alloc] initWithPackage:_packageName service:_serviceName method:method];
62  return [[GRPCProtoCall alloc] initWithHost:_host
63                                      method:methodName
64                              requestsWriter:requestsWriter
65                               responseClass:responseClass
66                          responsesWriteable:responsesWriteable];
67}
68@end
69
70@implementation GRPCProtoService
71
72@end
73