ClientChannel Class |
Namespace: OBCOM.NetSwitchLib.Clients
The ClientChannel type exposes the following members.
Name | Description | |
---|---|---|
ClientChannel |
Constructs a new ClientChannel instance.
|
Name | Description | |
---|---|---|
IsConnected |
Gets a value that indicates whether this channel is connected.
(Inherited from ChannelBase.) | |
IsSecure |
Gets a value that indicates whether this channel is secure
(Inherited from ChannelBase.) | |
KeepAlive |
Gets or sets a value that indicates whether the KeepAlive
option of this channel is active.
(Inherited from ChannelBase.) | |
Name |
Gets the name of this channel.
| |
ReaderBufferFreeSize |
Gets or sets the free size of the reader buffer (bytes).
(Inherited from ChannelBase.) | |
ReaderBufferMaxSize |
Gets or sets the maximum size of the reader buffer (bytes).
(Inherited from ChannelBase.) | |
ReaderBufferMinSize |
Gets or sets the minimum size of the reader buffer (bytes).
(Inherited from ChannelBase.) | |
ReaderBufferWarnSize |
Gets or sets the warning size of the reader buffer (bytes).
(Inherited from ChannelBase.) | |
SwitchName |
Gets the name of the NetSwitch server connected to this channel.
| |
SwitchURI |
Gets the connection URI of this channel.
| |
SwitchVersion |
Gets the version of the NetSwitch server connected to this channel.
| |
Tag |
Gets a value that indicates the connection tag of this channel.
(Inherited from ChannelBase.) | |
TcpNoDelay |
Gets or sets a value that indicates whether this channel is using
the Nagle algorithm.
(Inherited from ChannelBase.) | |
Tracing |
Gets a value that indicates whether this channel is tracing inbound
and outbound messages.
(Inherited from ChannelBase.) | |
TrustStorePass |
Gets or sets the password of the PFX/PKCS12 trust store file used to
establish secure (SSL/TLS) connections.
(Inherited from ChannelBase.) | |
TrustStorePath |
Gets or sets the path of the PFX/PKCS12 trust store file used to
establish secure (SSL/TLS) connections.
(Inherited from ChannelBase.) | |
Version |
Gets the implementation version of this channel.
|
Name | Description | |
---|---|---|
Connect(String, Properties) |
Connects this channel to a NetSwitch server using supplied name and props.
| |
Connect(String, String) |
Connects this channel to a NetSwitch server using supplied name and nameOrUri.
| |
Connect(String, String, String, String) |
Connects this channel to a NetSwitch server using supplied name, nameOrUri, username and password.
| |
DisableMulticast |
Disables the reception of multicast messages identified by name. If name has the special value
"*", then this method disables the reception of all multicast
messages that have been enabled using the EnableMulticast(String, MulticastHandler) method.
| |
Dispose |
Dispose managed and unmanaged objects.
(Overrides ChannelBaseDispose.) | |
EnableMulticast |
Enables the reception of multicast messages identified by name. Multicast messages are generated when particular
event occurs (e.g., the price of a stock has reached a certain
limit). When a multicast message arrives, the supplied handler is called.
| |
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) | |
GetHashCode | Serves as the default hash function. (Inherited from Object.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
Inform |
Logs an information message.
(Inherited from ChannelBase.) | |
SendMulticast |
Sends an multicast message built using the supplied name and data. The message will be
dispatched to all client and/or server applications that have
enabled the reception of multicast messages with the specified
name.
| |
SendRequest(String, Object) |
Sends a request message to a destination and then
blocks forever waiting for the reply message.
| |
SendRequest(String, Object, Int32) |
Sends a request message to a destination and then
blocks forever waiting for the reply message.
| |
Severe(String) |
Logs an error message.
(Inherited from ChannelBase.) | |
Severe(Exception, String) |
Logs an error message with associated ex.
(Inherited from ChannelBase.) | |
ToString | Returns a string that represents the current object. (Inherited from Object.) | |
Warning |
Logs a warning message.
(Inherited from ChannelBase.) | |
WriteMessage |
Writes the message to this channel.
(Inherited from ChannelBase.) |
Name | Description | |
---|---|---|
UnexpectedReply |
Occurs when an unexpected reply message is received.
|
An application usse a ClientChannel to send transactions, receive multicast data, and request other services from custom made servers (see ServerChannel for details about building custom servers).
The communication channel is established as late as possible. Yet, once established, it is kept running until a system operator executes the "kill client" command in an NetSwitch Console. If the communication channel is lost for any other reason, it is automatically re-established as soon as possible.
In order to maximize reusability and to reduce the number of physical network connections, the ClientChannel communication link is implemented as a shared (multiplexed) channel. For this reason, a client application cannot use a ClientChannel directly, but it has to acquire a LogicalChannel instance using the ExecuteT(ChannelExecutorT) method. It is through this LogicalChannel that the client application communicates with the NetSwitch environment.
The following example uses a ClientChannel named SampleClient to obtain the date from a server called ACASER. This is accomplished by sending a transaction named ACA-TIME to the ACASER server. If an error occurs while processing this transaction, the reply code of the reply message will not be SUCCESS. In this case, an exception is thrown with a message obtained from the Data of the reply message. If successful, the LogicalChannel is released and the server's date is retrieved from a field called ACC_FECHA of the reply message and displayed in the system console.
The following table describes the properties of a ClientChannel:
Property | Description | Type | Default |
---|---|---|---|
netswitch.client.«name».channel.password | Password use to authenticate the client channel | string | none |
netswitch.client.«name».keep.alive | Enable or disable the socket SO_KEEPALIVE option | bool | false |
netswitch.client.«name».reply.timeout | Maximum time to wait for reply of connect message (milliseconds) | int | 10000 |
netswitch.client.«name».reader.buffer.free | Free size of the reader buffer (bytes) | int | 4096 |
netswitch.client.«name».reader.buffer.max | Maximum size of the reader buffer (bytes) | int | 0 (unbounded) |
netswitch.client.«name».reader.buffer.min | Minimum size of the reader buffer (bytes) | int | 8192 |
netswitch.client.«name».reader.buffer.warn | Warning size of the reader buffer (bytes) | int | 8192 |
netswitch.client.«name».switch.uri | Protocol, address and port of the NetSwitch server | string | NETSWITCH |
netswitch.client.«name».tcp.nodelay | Enable or disable the socket TCP_NODELAY option | bool | true |
netswitch.client.«name».trace | Trace inbound and outbound messages (for debugging) | bool | false |
netswitch.client.«name».trust.store.path | Path of the PFX/PKCS12 trust store file used for SSL/TLS connections | string | none |
netswitch.client.«name».trust.store.pass | Password of the PFX/PKCS12 trust store file used for SSL/TLS connections | string | none |
netswitch.client.«name».user.name | Username used to login the channel with the NetSwitch server | string | none |
netswitch.client.«name».user.password | Password used to login the channel with the NetSwitch server | string | none |
using OBCOM.NetSwitchLib.Clients; using OBCOM.NetSwitchLib.Messages; public class SampleClient { public static void Main(string[] args) { // Create client channel named "SAMPLE_CLIENT". ClientChannel channel = new ClientChannel(); client.Connect("SAMPLE_CLIENT", "tcp://localhost:10214"); // Send request to "ACASER" server and check reply status. Message reply = client.SendRequest("ACASER.ACA-TIME", null); if (reply.Status != Message.SUCCESS) throw new Exception(reply.Text); // Build a layout message with information returned in reply message. LayoutLoader layoutLoader = new LayoutLoader("http://localhost/layouts/*.asp"); LayoutMessage layoutReply = new LayoutMessage(reply.Text) { Layout = layoutLoader.GetLayout(reply.GetLabel(Label.LayoutName)) }; // Display date contained in the "ACASER" layout reply message. Console.WriteLine($"The date is {layoutReply.GetDate("ACC_FECHA")}"); } }