IGLib  1.5
The IGLib base library for development of numerical, technical and business applications.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events
IG.Lib.Copy.ClienServerStreamBase Class Reference

Base class for client and server classes with stream-based communication. More...

+ Inheritance diagram for IG.Lib.Copy.ClienServerStreamBase:
+ Collaboration diagram for IG.Lib.Copy.ClienServerStreamBase:

Public Member Functions

delegate string ResponseDelegate (string request)
 Provides an answer string to the specified request string. More...
 
void SetMessagePreix (string messagePrefix)
 Changes message prefix for the current object. More...
 
void SetMessageSeparator (char messageSeparator)
 Changes message separator for the current object. More...
 
void SetMessageFalseSeparator (char messageFalseSeparator)
 Changes message false separator for the current object. More...
 
string CreateMessage (string messageName, string[] messageArguments)
 Creates a built-in message (possibly with arguments) that is to be interpreted directly by the receiver (stream client or server) and is not executed via ordinary path. More...
 
string createResponseOrRequestString (string originalResponseOrRequestString)
 Generates request and response string in such a way that it can not be mixed up with a message. More...
 
void GetRequestOrResponse (ref string responseOrRequestString, out bool isMessage, out string messageOrCommandName, out string[] messageArguments)
 Returns the (eventually decoded) request or response string corresponding to the stirng that is read form the communication pipeline, and also parameters that specify whether the request string represents a message or not. Eventual command or message parameters are also returned. More...
 

Public Attributes

const int MinimalMessagePreffixLength = 3
 

Protected Attributes

object _lock = new object()
 

Properties

object Lock [get]
 Objectt for locking the current object. More...
 
static object LockGlobal [get]
 Static lock object used by all instances of this class (and possibly by other classes). More...
 
static string DefaultMessagePrefix [get, set]
 
static char DefaultMessageSeparator [get, set]
 
static char DefaultMessageFalseSeparator [get, set]
 
string MessagePrefix [get, protected set]
 
char MessageSeparator [get, protected set]
 
char MessageFalseSeparator [get, protected set]
 
string MessagePrefixWithSeparator [get, protected set]
 Gets the mesage prefix with separator. If some string is a message, everything that follows this string until the first separator is a message name. More...
 
StringBuilder StringBuilderInternal [get]
 
static int DefaultOutputLevel [get, set]
 Default level of output for this kind of class. More...
 
virtual int OutputLevel [get, set]
 Level of output generated by operatins. More...
 
- Properties inherited from IG.Lib.ILockable
object Lock [get]
 

Private Attributes

string _messagePrefix = DefaultMessagePrefix
 
char _messageSeparator = DefaultMessageSeparator
 
char _messageFalseSeparator = DefaultMessageFalseSeparator
 
string _messagePrefixWithSeparator = null
 
StringBuilder _sb = new StringBuilder()
 
int _otputLevel = DefaultOutputLevel
 

Static Private Attributes

static object _lockGlobal = null
 
static string _defaultMessagePrefix = "IGLibMessage"
 
static char _defaultMessageSeparator = '_'
 
static char _defaultMessageFalseSeparator = '.'
 
static int _defatultOutputLevel = 1
 

Detailed Description

Base class for client and server classes with stream-based communication.

$A Igor xx Aug14;

Member Function Documentation

delegate string IG.Lib.Copy.ClienServerStreamBase.ResponseDelegate ( string  request)

Provides an answer string to the specified request string.

Parameters
requestRequest string.
Returns
Answer to the request.
void IG.Lib.Copy.ClienServerStreamBase.SetMessagePreix ( string  messagePrefix)
inline

Changes message prefix for the current object.

This setter method is provided in order to keep the MessagePrefix setter protected.

Parameters
messagePrefixNew message prefix. Must be at least MinimalMessagePreffixLength characters long.
void IG.Lib.Copy.ClienServerStreamBase.SetMessageSeparator ( char  messageSeparator)
inline

Changes message separator for the current object.

This setter method is provided in order to keep the MessageSeparator setter protected.

Parameters
messagePrefixNew message separator must not be a separator or a white space character.
void IG.Lib.Copy.ClienServerStreamBase.SetMessageFalseSeparator ( char  messageFalseSeparator)
inline

Changes message false separator for the current object.

This setter method is provided in order to keep the MessageFalseSeparator setter protected.

Parameters
messagePrefixNew message false separator must not be a separator or a white space character.
string IG.Lib.Copy.ClienServerStreamBase.CreateMessage ( string  messageName,
string[]  messageArguments 
)
inline

Creates a built-in message (possibly with arguments) that is to be interpreted directly by the receiver (stream client or server) and is not executed via ordinary path.

Messages commands are composed of message prefix, separator (jointly MessagePrefixWithSeparator), and message name. The first two are fixed parts whire the latter varies and defines the message.

Parameters
messageNameName of the message (a kind of command name).
messageArgumentsOptional arguments of the message.
Returns
string IG.Lib.Copy.ClienServerStreamBase.createResponseOrRequestString ( string  originalResponseOrRequestString)
inline

Generates request and response string in such a way that it can not be mixed up with a message.

If the original string begins with the message prefix theen a false separator is inserted after the part that is the same as message prefix. In this way the string can be distinguished form a message and can be correctly decoded on the other side of the communication pipeline (simply by removng the false separator).

Parameters
originalResponseOrRequestStringOriginal response string that is sent to the other side.
Returns
The created request string that can be distinguished form a command.
void IG.Lib.Copy.ClienServerStreamBase.GetRequestOrResponse ( ref string  responseOrRequestString,
out bool  isMessage,
out string  messageOrCommandName,
out string[]  messageArguments 
)
inline

Returns the (eventually decoded) request or response string corresponding to the stirng that is read form the communication pipeline, and also parameters that specify whether the request string represents a message or not. Eventual command or message parameters are also returned.

Parameters
responseOrRequestStringOriginal response or request string that is to be decoded.
isMessageOutput flag telling whether the string is a message or not.
messageOrCommandNameName of the message or command extracted from the string.
messageArgumentsMessage or command arguments.

Member Data Documentation

object IG.Lib.Copy.ClienServerStreamBase._lock = new object()
protected
object IG.Lib.Copy.ClienServerStreamBase._lockGlobal = null
staticprivate
const int IG.Lib.Copy.ClienServerStreamBase.MinimalMessagePreffixLength = 3
string IG.Lib.Copy.ClienServerStreamBase._defaultMessagePrefix = "IGLibMessage"
staticprivate
char IG.Lib.Copy.ClienServerStreamBase._defaultMessageSeparator = '_'
staticprivate
char IG.Lib.Copy.ClienServerStreamBase._defaultMessageFalseSeparator = '.'
staticprivate
string IG.Lib.Copy.ClienServerStreamBase._messagePrefix = DefaultMessagePrefix
private
char IG.Lib.Copy.ClienServerStreamBase._messageSeparator = DefaultMessageSeparator
private
char IG.Lib.Copy.ClienServerStreamBase._messageFalseSeparator = DefaultMessageFalseSeparator
private
string IG.Lib.Copy.ClienServerStreamBase._messagePrefixWithSeparator = null
private
StringBuilder IG.Lib.Copy.ClienServerStreamBase._sb = new StringBuilder()
private
int IG.Lib.Copy.ClienServerStreamBase._defatultOutputLevel = 1
staticprivate
int IG.Lib.Copy.ClienServerStreamBase._otputLevel = DefaultOutputLevel
private

Property Documentation

object IG.Lib.Copy.ClienServerStreamBase.Lock
get

Objectt for locking the current object.

object IG.Lib.Copy.ClienServerStreamBase.LockGlobal
staticget

Static lock object used by all instances of this class (and possibly by other classes).

string IG.Lib.Copy.ClienServerStreamBase.DefaultMessagePrefix
staticgetset
char IG.Lib.Copy.ClienServerStreamBase.DefaultMessageSeparator
staticgetset
char IG.Lib.Copy.ClienServerStreamBase.DefaultMessageFalseSeparator
staticgetset
string IG.Lib.Copy.ClienServerStreamBase.MessagePrefix
getprotected set
char IG.Lib.Copy.ClienServerStreamBase.MessageSeparator
getprotected set
char IG.Lib.Copy.ClienServerStreamBase.MessageFalseSeparator
getprotected set
string IG.Lib.Copy.ClienServerStreamBase.MessagePrefixWithSeparator
getprotected set

Gets the mesage prefix with separator. If some string is a message, everything that follows this string until the first separator is a message name.

A protected getter is defined that is only allowed to set the property to null (invalidate it). If a non-null value is set then an exception is thrown.

StringBuilder IG.Lib.Copy.ClienServerStreamBase.StringBuilderInternal
getprotected
int IG.Lib.Copy.ClienServerStreamBase.DefaultOutputLevel
staticgetset

Default level of output for this kind of class.

virtual int IG.Lib.Copy.ClienServerStreamBase.OutputLevel
getset

Level of output generated by operatins.


The documentation for this class was generated from the following file: