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 <Foundation/Foundation.h> 20 21 #include <grpc/grpc.h> 22 23 @class GRPCCompletionQueue; 24 struct grpc_channel_credentials; 25 26 /** 27 * Each separate instance of this class represents at least one TCP connection to the provided host. 28 */ 29 @interface GRPCChannel : NSObject 30 31 @property(nonatomic, readonly, nonnull) struct grpc_channel *unmanagedChannel; 32 33 - (nullable instancetype)init NS_UNAVAILABLE; 34 35 /** 36 * Creates a secure channel to the specified @c host using default credentials and channel 37 * arguments. If certificates could not be found to create a secure channel, then @c nil is 38 * returned. 39 */ 40 + (nullable GRPCChannel *)secureChannelWithHost:(nonnull NSString *)host; 41 42 /** 43 * Creates a secure channel to the specified @c host using Cronet as a transport mechanism. 44 */ 45 #ifdef GRPC_COMPILE_WITH_CRONET 46 + (nullable GRPCChannel *)secureCronetChannelWithHost:(nonnull NSString *)host 47 channelArgs:(nonnull NSDictionary *)channelArgs; 48 #endif 49 /** 50 * Creates a secure channel to the specified @c host using the specified @c credentials and 51 * @c channelArgs. Only in tests should @c GRPC_SSL_TARGET_NAME_OVERRIDE_ARG channel arg be set. 52 */ 53 + (nonnull GRPCChannel *)secureChannelWithHost:(nonnull NSString *)host 54 credentials: 55 (nonnull struct grpc_channel_credentials *)credentials 56 channelArgs:(nullable NSDictionary *)channelArgs; 57 58 /** 59 * Creates an insecure channel to the specified @c host using the specified @c channelArgs. 60 */ 61 + (nonnull GRPCChannel *)insecureChannelWithHost:(nonnull NSString *)host 62 channelArgs:(nullable NSDictionary *)channelArgs; 63 64 - (nullable grpc_call *)unmanagedCallWithPath:(nonnull NSString *)path 65 serverName:(nonnull NSString *)serverName 66 timeout:(NSTimeInterval)timeout 67 completionQueue:(nonnull GRPCCompletionQueue *)queue; 68 @end 69