|
|
@ -45,9 +45,13 @@ namespace Grpc.Core |
|
|
|
readonly string target; |
|
|
|
readonly string target; |
|
|
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// <summary> |
|
|
|
/// Creates a channel. |
|
|
|
/// 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> |
|
|
|
/// </summary> |
|
|
|
public Channel(string target, Credentials credentials = null, ChannelArgs channelArgs = null) |
|
|
|
/// <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="channelArgs">Optional channel arguments.</param> |
|
|
|
|
|
|
|
public Channel(string host, Credentials credentials = null, ChannelArgs channelArgs = null) |
|
|
|
{ |
|
|
|
{ |
|
|
|
using (ChannelArgsSafeHandle nativeChannelArgs = CreateNativeChannelArgs(channelArgs)) |
|
|
|
using (ChannelArgsSafeHandle nativeChannelArgs = CreateNativeChannelArgs(channelArgs)) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -55,23 +59,27 @@ namespace Grpc.Core |
|
|
|
{ |
|
|
|
{ |
|
|
|
using (CredentialsSafeHandle nativeCredentials = credentials.ToNativeCredentials()) |
|
|
|
using (CredentialsSafeHandle nativeCredentials = credentials.ToNativeCredentials()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
this.handle = ChannelSafeHandle.CreateSecure(nativeCredentials, target, nativeChannelArgs); |
|
|
|
this.handle = ChannelSafeHandle.CreateSecure(nativeCredentials, host, nativeChannelArgs); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
this.handle = ChannelSafeHandle.Create(target, nativeChannelArgs); |
|
|
|
this.handle = ChannelSafeHandle.Create(host, nativeChannelArgs); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
this.target = GetOverridenTarget(target, channelArgs); |
|
|
|
this.target = GetOverridenTarget(host, channelArgs); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public string Target |
|
|
|
/// <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="channelArgs">Optional channel arguments.</param> |
|
|
|
|
|
|
|
public Channel(string host, int port, Credentials credentials = null, ChannelArgs channelArgs = null) : |
|
|
|
|
|
|
|
this(string.Format("{0}:{1}", host, port), credentials, channelArgs) |
|
|
|
{ |
|
|
|
{ |
|
|
|
get |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return this.target; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void Dispose() |
|
|
|
public void Dispose() |
|
|
@ -80,6 +88,14 @@ namespace Grpc.Core |
|
|
|
GC.SuppressFinalize(this); |
|
|
|
GC.SuppressFinalize(this); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
internal string Target |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
get |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return target; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
internal ChannelSafeHandle Handle |
|
|
|
internal ChannelSafeHandle Handle |
|
|
|
{ |
|
|
|
{ |
|
|
|
get |
|
|
|
get |
|
|
|