예제 #1
0
파일: Channel.cs 프로젝트: mway08/grpc
 /// <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);
 }
예제 #2
0
파일: Channel.cs 프로젝트: kdavison/grpc
 /// <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);
 }
예제 #3
0
파일: Channel.cs 프로젝트: rootusr/grpc
        /// <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">Credentials to secure the channel.</param>
        /// <param name="options">Channel options.</param>
        public Channel(string host, Credentials credentials, IEnumerable<ChannelOption> options = null)
        {
            this.environment = GrpcEnvironment.GetInstance();
            this.options = options != null ? new List<ChannelOption>(options) : new List<ChannelOption>();

            EnsureUserAgentChannelOption(this.options);
            using (CredentialsSafeHandle nativeCredentials = credentials.ToNativeCredentials())
            using (ChannelArgsSafeHandle nativeChannelArgs = ChannelOptions.CreateChannelArgs(this.options))
            {
                if (nativeCredentials != null)
                {
                    this.handle = ChannelSafeHandle.CreateSecure(nativeCredentials, host, nativeChannelArgs);
                }
                else
                {
                    this.handle = ChannelSafeHandle.CreateInsecure(host, nativeChannelArgs);
                }
            }
            this.target = GetOverridenTarget(host, this.options);
        }
예제 #4
0
파일: Channel.cs 프로젝트: gpndata/grpc
        /// <summary>
        /// Creates a channel that connects to a specific host.
        /// Port will default to 80 for an unsecure channel and to 443 for a secure channel.
        /// </summary>
        /// <param name="target">Target of the channel.</param>
        /// <param name="credentials">Credentials to secure the channel.</param>
        /// <param name="options">Channel options.</param>
        public Channel(string target, Credentials credentials, IEnumerable<ChannelOption> options = null)
        {
            this.target = Preconditions.CheckNotNull(target, "target");
            this.environment = GrpcEnvironment.AddRef();
            this.options = options != null ? new List<ChannelOption>(options) : new List<ChannelOption>();

            EnsureUserAgentChannelOption(this.options);
            using (CredentialsSafeHandle nativeCredentials = credentials.ToNativeCredentials())
            using (ChannelArgsSafeHandle nativeChannelArgs = ChannelOptions.CreateChannelArgs(this.options))
            {
                if (nativeCredentials != null)
                {
                    this.handle = ChannelSafeHandle.CreateSecure(nativeCredentials, target, nativeChannelArgs);
                }
                else
                {
                    this.handle = ChannelSafeHandle.CreateInsecure(target, nativeChannelArgs);
                }
            }
        }
예제 #5
0
파일: Channel.cs 프로젝트: rootusr/grpc
 /// <summary>
 /// Creates a channel that connects to a specific host and port.
 /// </summary>
 /// <param name="host">DNS name or IP address</param>
 /// <param name="port">the port</param>
 /// <param name="credentials">Credentials to secure the channel.</param>
 /// <param name="options">Channel options.</param>
 public Channel(string host, int port, Credentials credentials, IEnumerable<ChannelOption> options = null)
     : this(string.Format("{0}:{1}", host, port), credentials, options)
 {
 }
예제 #6
0
파일: Channel.cs 프로젝트: hmings888/grpc
 /// <summary>
 /// Creates a channel that connects to a specific host and port.
 /// </summary>
 /// <param name="host">DNS name or IP address</param>
 /// <param name="port">the port</param>
 /// <param name="credentials">Optional credentials to create a secure channel.</param>
 /// <param name="options">Channel options.</param>
 public Channel(string host, int port, Credentials credentials = null, IEnumerable <ChannelOption> options = null) :
     this(string.Format("{0}:{1}", host, port), credentials, options)
 {
 }