Debian Codegraph @

src/objective-c/GRPCClient/private/GRPCCore/GRPCInsecureChannelFactory.m

raw
1 /*
2 *
3 * Copyright 2018 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 "GRPCInsecureChannelFactory.h"
20
21 #include <grpc/grpc_security.h>
22
23 #import "ChannelArgsUtil.h"
24 #import "GRPCChannel.h"
25
26 @implementation GRPCInsecureChannelFactory
27
28 + (instancetype)sharedInstance {
29 static GRPCInsecureChannelFactory *instance;
30 static dispatch_once_t onceToken;
31 dispatch_once(&onceToken, ^{
32 instance = [[self alloc] init];
33 });
34 return instance;
35 }
36
37 - (grpc_channel *)createChannelWithHost:(NSString *)host channelArgs:(NSDictionary *)args {
38 grpc_channel_args *coreChannelArgs = GRPCBuildChannelArgs(args);
39 grpc_channel_credentials *creds = grpc_insecure_credentials_create();
40 grpc_channel *unmanagedChannel = grpc_channel_create(host.UTF8String, creds, coreChannelArgs);
41 grpc_channel_credentials_release(creds);
42 GRPCFreeChannelArgs(coreChannelArgs);
43 return unmanagedChannel;
44 }
45
46 @end