/// <summary> /// Creates a channel. /// </summary> public Channel(string target, Credentials credentials = null, ChannelArgs channelArgs = null) { using (ChannelArgsSafeHandle nativeChannelArgs = CreateNativeChannelArgs(channelArgs)) { if (credentials != null) { using (CredentialsSafeHandle nativeCredentials = credentials.ToNativeCredentials()) { this.handle = ChannelSafeHandle.CreateSecure(nativeCredentials, target, nativeChannelArgs); } } else { this.handle = ChannelSafeHandle.Create(target, nativeChannelArgs); } } this.target = GetOverridenTarget(target, channelArgs); }
/// <summary> /// Creates a channel that connects to a specific host. /// Port will default to 80 for an unsecure channel and to 443 a secure channel. /// </summary> /// <param name="host">The DNS name of IP address of the host.</param> /// <param name="credentials">Optional credentials to create a secure channel.</param> /// <param name="options">Channel options.</param> public Channel(string host, Credentials credentials = null, IEnumerable <ChannelOption> options = null) { using (ChannelArgsSafeHandle nativeChannelArgs = ChannelOptions.CreateChannelArgs(options)) { if (credentials != null) { using (CredentialsSafeHandle nativeCredentials = credentials.ToNativeCredentials()) { this.handle = ChannelSafeHandle.CreateSecure(nativeCredentials, host, nativeChannelArgs); } } else { this.handle = ChannelSafeHandle.Create(host, nativeChannelArgs); } } this.target = GetOverridenTarget(host, options); }
// TODO: add way how to create grpc_secure_channel.... // TODO: add support for channel args... public Channel(string target) { this.handle = ChannelSafeHandle.Create(target, IntPtr.Zero); this.target = target; }