ServerChannel Class |
Namespace: OBCOM.NetSwitchLib.Servers
The ServerChannel type exposes the following members.
Name | Description | |
---|---|---|
ServerChannel |
Constructs a new ServerChannel instance.
|
Name | Description | |
---|---|---|
Arguments |
Gets the command arguments supplied to the Main method of
this channel.
| |
IdleTimeout |
Gets or sets the idle timeout of this server channel (milliseconds).
| |
IsConnected |
Gets a value that indicates whether this channel is connected.
(Inherited from ChannelBase.) | |
IsExecuting |
Gets a value that indicates if this channel is executing.
| |
IsSecure |
Gets a value that indicates whether this channel is secure
(Inherited from ChannelBase.) | |
IsServerThread |
Gets a value that indicates if running in the server thread.
| |
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 to which this channel is connected.
| |
SwitchReplyTimeout |
Gets or sets the maximum time to wait for a NetSwitch reply
(milliseconds).
| |
SwitchURI |
Gets the URI of the NetSwitch to which this channel is connected.
| |
SwitchVersion |
Gets the version of the NetSwitch to which this channel is connected.
| |
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.) | |
UniqueName |
Gets the unique name of this channel.
| |
Version |
Gets a string with the implementation version of this channel.
|
Name | Description | |
---|---|---|
AddRequestHandler |
Registers a handler identified by the supplied
name.
| |
CancelTimer |
Cancels the execution of the HandleTimer method.
| |
ClearStatistics |
Clears the statistics of a specific service or all services.
| |
Connect |
Connects this channel to serverURI.
(Inherited from ChannelBase.) | |
DecodePassword |
Decodes an encoded password using supplied arguments.
| |
DefineHistogram |
Defines the execution histogram of a specific service or all
services.
| |
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.) | |
Execute(String) |
Starts the execution of this ServerChannel.
| |
Execute(String, IServerContext) |
Starts the execution of this ServerChannel.
| |
Execute(String, Properties, IServerContext) |
Starts the execution of this ServerChannel.
| |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | |
GetHashCode | Serves as the default hash function. (Inherited from Object.) | |
GetProperties |
Returns all the properties of this channel.
| |
GetProperty(String) |
Gets the value of a property indexed by the specified name.
| |
GetProperty(String, String) |
Gets the value of a property indexed by the specified name.
| |
GetStatistics |
Returns a list with statistics of a specific service or all services.
| |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
HandleIdle |
Called when a idle event occurs.
| |
HandleInbound |
Handles an inbound message received by this channel.
(Overrides ChannelBaseHandleInbound(Message).) | |
HandleInitialize |
Called just after this channel connects to the NetSwitch server.
| |
HandleReinitialize |
Called just after a console REINIT command is executed.
| |
HandleStop |
Called when a stop message is received.
| |
HandleTimer |
Called when a timer event occurs.
| |
Inform |
Logs an information message.
(Inherited from ChannelBase.) | |
LogRequestError |
Logs the error that was thrown while processing a request message.
| |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
RemoveRequestHandler |
Unregisters the request handler identified by supplied name.
| |
ReplyCompleted |
Called after an asynchronous reply message has been successfully
processed by a ReplyHandler method.
| |
ReplyError |
Called after an exception is thrown while processing an asynchronous
reply message.
| |
ReplyReceived |
Called after an asynchronous reply message has been received and
before it is processed by a ReplyHandler method.
| |
RequestCompleted |
Called after a request message has been successfully processed by a
RequestHandler method.
| |
RequestError |
Called after an exception is thrown while processing a request
message.
| |
RequestReceived |
Called after a request message has been received and before it is
processed by a RequestHandler method.
| |
RunAsyncTaskT |
Executes the supplied task in a separate thread.
| |
RunLater |
Runs an action on the server's thread at some time in the future.
| |
SendMail(String, String) |
Sends a mail message using the "default" SMTP mail session.
| |
SendMail(String, String, String) |
Sends a mail message using the specified SMTP mail session.
| |
SendMessage |
Sends a request message to a destination.
| |
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, ReplyHandler) |
Sends a request message to a destination and then
calls handler when the asynchronous reply is
received.
| |
SendRequest(String, Object, Int32) |
Sends a request message to a destination and then
blocks waiting for the reply until timeout.
| |
SendRequest(String, Object, ReplyHandler, Int32) |
Sends a request message to a destination and then
calls handler when the asynchronous reply is
received.
| |
Severe(String) |
Logs an error message.
(Inherited from ChannelBase.) | |
Severe(Exception, String) |
Logs an error message with associated ex.
(Inherited from ChannelBase.) | |
StartTimer |
Schedules the execution of the HandleTimer method at
regular intervals.
| |
Stop |
Stops the execution of this server channel.
| |
Stop(String) |
Stops the execution of this server channel with a reason.
| |
ToString | Returns a string that represents the current object. (Inherited from Object.) | |
Warning |
Logs a warning message.
(Inherited from ChannelBase.) | |
WriteLog |
Writes the supplied log message with specified level.
(Inherited from ChannelBase.) | |
WriteMessage |
Writes the message to this channel.
(Inherited from ChannelBase.) |
Once the communcation is established with the NetServer, the application is able to receive transaction requests, send unsolicited data, and provide other services to the clients of a NetSwitch server.
A server application is constructed by extending the ServerChannel class and then overriding the ProcessXXXXXXX methods. For example, the ProcessTransaction method is called each time the server receives a transaction request from an NetServer client application (see ClientChannel for details about building NetServer client applications).
The following table describes the properties of a ServerChannel:
Property | Description | Type | Default |
---|---|---|---|
netswitch.uri | Protocol, address and port of the NetSwitch server | string | NETSWITCH |
netswitch.password | Password use to authenticate the server channel | string | none |
netswitch.server.keep.alive | Enable or disable the socket SO_KEEPALIVE option | bool | false |
netswitch.server.reader.buffer.free | Free size of the reader buffer (bytes) | int | 4096 |
netswitch.server.reader.buffer.max | Maximum size of the reader buffer (bytes) | int | 0 (unbounded) |
netswitch.server.reader.buffer.min | Minimum size of the reader buffer (bytes) | int | 8192 |
netswitch.server.reader.buffer.warn | Warning size of the reader buffer (bytes) | int | 8192 |
netswitch.server.reply.timeout | Maximum time to wait for a NetSwitch reply (milliseconds) | int | 800 |
netswitch.server.tcp.nodelay | Enable or disable the socket TCP_NODELAY option | bool | true |
netswitch.server.trace | Trace inbound and outbound messages (for debugging) | bool | false |
netswitch.server.trust.store | Path of the JKS trust store file used for SSL connections | string | none |
netswitch.server.writer.queue.size | Maximum size of the writer queue (messages) | int | 64 |
The following example uses ServerChannel to implement a server application named "SampleServer". This server is very simple: it just sends a reply to Hello service requests:
using OBCOM.NetSwitchLib.Servers; public class SampleServer : ServerChannel { // Called after SampleServer connects to NetSwitch. protected override void HandleInitialize() { AddRequestHandler("Hello", HelloService); } // Called when a <c>Hello</c> service request is received. private void HelloService(RequestEvent request) { request.SendReply($"Hello to you too, {request.Message.Text}"); } // Startup method of SampleServer. public static void Main(string[] args) { new SampleServer().Execute("SAMPLE_SERVER"); } }