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

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

+ Inheritance diagram for IG.Lib.IpcStreamClientServerBase:
+ Collaboration diagram for IG.Lib.IpcStreamClientServerBase:

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 messageSeparator (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, bool multiLine)
 Generates request and response string in such a way that it can not be mixed up with a message. More...
 
void InterpretRequestOrResponseLine (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...
 
void WriteMessage (StreamWriter outputStream, string message, string[] args)
 Writes a mesage to the output stream. What is written is decorated message (including the standard message prefix and separator) and message arguments. More...
 
virtual void WorkMessage (string messageName, string[] messageArguments, IpcStage context, ref bool worked)
 
virtual void RespondToMessage (string messageName, string[] messageArguments, ref bool responded)
 Responds to a received message. 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...
 
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...
 
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...
 
static string DefaultMsgRequestBegin [get]
 Default message that begins any mulltiline request. More...
 
static string DefaultMsgRequestEnd [get]
 Default message that ends any mulltiline request. More...
 
static string DefaultMsgResponseBegin [get]
 Default message that begins any multiline response. More...
 
static string DefaultMsgResponseEnd [get]
 Default message that ends any multiline response. More...
 
static string DefaultMsgTestSquare [get]
 Default message that requests a test computation of square to be performed on the other side (a sort of ping command). More...
 
static string DefaultMsgTestSpeed [get]
 Default message that requests a speed test to be performed on the other side (a sort of ping command). More...
 
string MsgRequestBegin [get, protected set]
 
string MsgRequestEnd [get, protected set]
 
string MsgResponseBegin [get, protected set]
 Message that begins any multiline response (only when multiline responses are allowed). More...
 
string MsgResponseEnd [get, protected set]
 Message that ends any multiline response (only when multiline responses are allowed). More...
 
string MsgTestSquare [get, protected set]
 Message that requests square of its argument to be sent back. Used as a kind of verifiable ping. More...
 
string MsgTestSpeed [get, protected set]
 Message that requires a kind of speed test to be performed on the other side. More...
 
static string DefaultStopRequest [get, set]
 Default stop request string - request string that will stop the server. More...
 
string StopRequest [get, set]
 Request that causes the server stop listening and closing the pipe. More...
 
static string DefaultGenericResponse [get, set]
 Default generic response (sent in absence of any other method to generate the response). More...
 
string GenericResponse [get, protected set]
 Generic response that is sent back to the client in abscence of any method generating responses to specific requests. More...
 
static string DefaultStoppedResponse [get, set]
 Default stopped response (sent after the srver has sttopped on request). More...
 
string StoppedResponse [get, protected set]
 Stopped response that is sent back to the client after the server stops on its request. More...
 
static bool DefaultIsMultilineResponse [get]
 Default pipe name. More...
 
static bool DefaultIsMultilineRequest [get]
 Default pipe name. More...
 
virtual bool IsMultilineRequest [get, protected set]
 Whether or not multi line requests are allowed. More...
 
virtual bool IsMultilineResponse [get, protected set]
 Whether or not multi line responses are allowed. More...
 
- Properties inherited from IG.Lib.ILockable
object Lock [get]
 

Private Attributes

StringBuilder _sb = new StringBuilder()
 
int _otputLevel = DefaultOutputLevel
 
string _messagePrefix = DefaultMessagePrefix
 
char _messageSeparator = DefaultMessageSeparator
 
char _messageFalseSeparator = DefaultMessageFalseSeparator
 
string _messagePrefixWithSeparator = null
 
string _msgRequestBegin = DefaultMsgRequestBegin
 Message that begins any multiline request (only when multiline requests are allowed). More...
 
string _msgRequestEnd = DefaultMsgRequestEnd
 Message that ends any multiline request (only when multiline requests are allowed). More...
 
string _msgResponseBegin = DefaultMsgResponseBegin
 
string _msgResponseEnd = DefaultMsgResponseEnd
 
string _msgTestSquare = DefaultMsgTestSquare
 
string _msgTestSpeed = DefaultMsgTestSpeed
 
string _stopRequest = DefaultStopRequest
 
string _genericResponse = DefaultGenericResponse
 
string _stoppedResponse = DefaultStoppedResponse
 
bool _isMultilineRequest = DefaultIsMultilineRequest
 
bool _isMultilineResponse = DefaultIsMultilineResponse
 

Static Private Attributes

static object _lockGlobal = null
 
static int _defatultOutputLevel = 1
 
static string _defaultMessagePrefix = "IGLibMsg"
 
static char _defaultMessageSeparator = '_'
 
static char _defaultMessageFalseSeparator = '.'
 
static string _defaultMsgRequestBegin = "RequestBegin"
 
static string _defaultMsgRequestEnd = "RequestEnd"
 
static string _defaultMsgResponseBegin = "ResponseBegin"
 
static string _defaultMsgResponseEnd = "ResponseEnd"
 
static string _defaultMsgTestSquare = "TestStuare"
 
static string _defaultMsgTestSpeed = "TestSpeed"
 
static string _defaultStopRequest = "stop"
 
static string _defaultGenericResponse = "IGLib_PipeServer_GenericResponse"
 
static string _defaultStoppedResponse = "IGLib_PipeServer_StoppedResponse"
 
static bool _defaultIsMultilineResponse = true
 
static bool _defaultIsMultilineRequest = true
 

Detailed Description

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

$A Igor xx Aug14;

Member Function Documentation

delegate string IG.Lib.IpcStreamClientServerBase.ResponseDelegate ( string  request)

Provides an answer string to the specified request string.

Parameters
requestRequest string.
Returns
Answer to the request.
void IG.Lib.IpcStreamClientServerBase.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.IpcStreamClientServerBase.messageSeparator ( char  messageSeparator)
inline

Changes message separator for the current object.

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

Parameters
messageSeparatorNew message separator must not be a separator or a white space character.
void IG.Lib.IpcStreamClientServerBase.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
messageFalseSeparatorNew message false separator must not be a separator or a white space character.
string IG.Lib.IpcStreamClientServerBase.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.IpcStreamClientServerBase.CreateResponseOrRequestString ( string  originalResponseOrRequestString,
bool  multiLine 
)
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.
multiLineSpecifies whether request or response, respectively, can be a multiline string.
Returns
The created request string that can be distinguished form a command.
void IG.Lib.IpcStreamClientServerBase.InterpretRequestOrResponseLine ( 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.
void IG.Lib.IpcStreamClientServerBase.WriteMessage ( StreamWriter  outputStream,
string  message,
string[]  args 
)
inline

Writes a mesage to the output stream. What is written is decorated message (including the standard message prefix and separator) and message arguments.

Parameters
outputStreamStream where the message is written to.
messageMessage name. The name is decorated with prefix and separator when message is written to a stream.
argsArguments of the message. Can be null for message without arguments.
virtual void IG.Lib.IpcStreamClientServerBase.WorkMessage ( string  messageName,
string[]  messageArguments,
IpcStage  context,
ref bool  worked 
)
inlinevirtual
virtual void IG.Lib.IpcStreamClientServerBase.RespondToMessage ( string  messageName,
string[]  messageArguments,
ref bool  responded 
)
inlinevirtual

Responds to a received message.

Parameters
messageNameName of the message upon which action is taken.
messageArgumentsArguments of the message.
respondedSet to true if message has already been responded.

Member Data Documentation

object IG.Lib.IpcStreamClientServerBase._lock = new object()
protected
object IG.Lib.IpcStreamClientServerBase._lockGlobal = null
staticprivate
StringBuilder IG.Lib.IpcStreamClientServerBase._sb = new StringBuilder()
private
int IG.Lib.IpcStreamClientServerBase._defatultOutputLevel = 1
staticprivate
int IG.Lib.IpcStreamClientServerBase._otputLevel = DefaultOutputLevel
private
const int IG.Lib.IpcStreamClientServerBase.MinimalMessagePreffixLength = 3
string IG.Lib.IpcStreamClientServerBase._defaultMessagePrefix = "IGLibMsg"
staticprivate
char IG.Lib.IpcStreamClientServerBase._defaultMessageSeparator = '_'
staticprivate
char IG.Lib.IpcStreamClientServerBase._defaultMessageFalseSeparator = '.'
staticprivate
string IG.Lib.IpcStreamClientServerBase._messagePrefix = DefaultMessagePrefix
private
char IG.Lib.IpcStreamClientServerBase._messageSeparator = DefaultMessageSeparator
private
char IG.Lib.IpcStreamClientServerBase._messageFalseSeparator = DefaultMessageFalseSeparator
private
string IG.Lib.IpcStreamClientServerBase._messagePrefixWithSeparator = null
private
string IG.Lib.IpcStreamClientServerBase._defaultMsgRequestBegin = "RequestBegin"
staticprivate
string IG.Lib.IpcStreamClientServerBase._defaultMsgRequestEnd = "RequestEnd"
staticprivate
string IG.Lib.IpcStreamClientServerBase._defaultMsgResponseBegin = "ResponseBegin"
staticprivate
string IG.Lib.IpcStreamClientServerBase._defaultMsgResponseEnd = "ResponseEnd"
staticprivate
string IG.Lib.IpcStreamClientServerBase._defaultMsgTestSquare = "TestStuare"
staticprivate
string IG.Lib.IpcStreamClientServerBase._defaultMsgTestSpeed = "TestSpeed"
staticprivate
string IG.Lib.IpcStreamClientServerBase._msgRequestBegin = DefaultMsgRequestBegin
private

Message that begins any multiline request (only when multiline requests are allowed).

string IG.Lib.IpcStreamClientServerBase._msgRequestEnd = DefaultMsgRequestEnd
private

Message that ends any multiline request (only when multiline requests are allowed).

string IG.Lib.IpcStreamClientServerBase._msgResponseBegin = DefaultMsgResponseBegin
private
string IG.Lib.IpcStreamClientServerBase._msgResponseEnd = DefaultMsgResponseEnd
private
string IG.Lib.IpcStreamClientServerBase._msgTestSquare = DefaultMsgTestSquare
private
string IG.Lib.IpcStreamClientServerBase._msgTestSpeed = DefaultMsgTestSpeed
private
string IG.Lib.IpcStreamClientServerBase._defaultStopRequest = "stop"
staticprivate
string IG.Lib.IpcStreamClientServerBase._stopRequest = DefaultStopRequest
private
string IG.Lib.IpcStreamClientServerBase._defaultGenericResponse = "IGLib_PipeServer_GenericResponse"
staticprivate
string IG.Lib.IpcStreamClientServerBase._genericResponse = DefaultGenericResponse
private
string IG.Lib.IpcStreamClientServerBase._defaultStoppedResponse = "IGLib_PipeServer_StoppedResponse"
staticprivate
string IG.Lib.IpcStreamClientServerBase._stoppedResponse = DefaultStoppedResponse
private
bool IG.Lib.IpcStreamClientServerBase._defaultIsMultilineResponse = true
staticprivate
bool IG.Lib.IpcStreamClientServerBase._defaultIsMultilineRequest = true
staticprivate
bool IG.Lib.IpcStreamClientServerBase._isMultilineRequest = DefaultIsMultilineRequest
private
bool IG.Lib.IpcStreamClientServerBase._isMultilineResponse = DefaultIsMultilineResponse
private

Property Documentation

object IG.Lib.IpcStreamClientServerBase.Lock
get

Objectt for locking the current object.

object IG.Lib.IpcStreamClientServerBase.LockGlobal
staticget

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

StringBuilder IG.Lib.IpcStreamClientServerBase.StringBuilderInternal
getprotected
int IG.Lib.IpcStreamClientServerBase.DefaultOutputLevel
staticgetset

Default level of output for this kind of class.

virtual int IG.Lib.IpcStreamClientServerBase.OutputLevel
getset
string IG.Lib.IpcStreamClientServerBase.DefaultMessagePrefix
staticgetset
char IG.Lib.IpcStreamClientServerBase.DefaultMessageSeparator
staticgetset
char IG.Lib.IpcStreamClientServerBase.DefaultMessageFalseSeparator
staticgetset
string IG.Lib.IpcStreamClientServerBase.MessagePrefix
getprotected set
char IG.Lib.IpcStreamClientServerBase.MessageSeparator
getprotected set
char IG.Lib.IpcStreamClientServerBase.MessageFalseSeparator
getprotected set
string IG.Lib.IpcStreamClientServerBase.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.

string IG.Lib.IpcStreamClientServerBase.DefaultMsgRequestBegin
staticget

Default message that begins any mulltiline request.

string IG.Lib.IpcStreamClientServerBase.DefaultMsgRequestEnd
staticget

Default message that ends any mulltiline request.

string IG.Lib.IpcStreamClientServerBase.DefaultMsgResponseBegin
staticget

Default message that begins any multiline response.

string IG.Lib.IpcStreamClientServerBase.DefaultMsgResponseEnd
staticget

Default message that ends any multiline response.

string IG.Lib.IpcStreamClientServerBase.DefaultMsgTestSquare
staticget

Default message that requests a test computation of square to be performed on the other side (a sort of ping command).

string IG.Lib.IpcStreamClientServerBase.DefaultMsgTestSpeed
staticget

Default message that requests a speed test to be performed on the other side (a sort of ping command).

string IG.Lib.IpcStreamClientServerBase.MsgRequestBegin
getprotected set
string IG.Lib.IpcStreamClientServerBase.MsgRequestEnd
getprotected set
string IG.Lib.IpcStreamClientServerBase.MsgResponseBegin
getprotected set

Message that begins any multiline response (only when multiline responses are allowed).

string IG.Lib.IpcStreamClientServerBase.MsgResponseEnd
getprotected set

Message that ends any multiline response (only when multiline responses are allowed).

string IG.Lib.IpcStreamClientServerBase.MsgTestSquare
getprotected set

Message that requests square of its argument to be sent back. Used as a kind of verifiable ping.

string IG.Lib.IpcStreamClientServerBase.MsgTestSpeed
getprotected set

Message that requires a kind of speed test to be performed on the other side.

string IG.Lib.IpcStreamClientServerBase.DefaultStopRequest
staticgetset

Default stop request string - request string that will stop the server.

string IG.Lib.IpcStreamClientServerBase.StopRequest
getset

Request that causes the server stop listening and closing the pipe.

string IG.Lib.IpcStreamClientServerBase.DefaultGenericResponse
staticgetset

Default generic response (sent in absence of any other method to generate the response).

string IG.Lib.IpcStreamClientServerBase.GenericResponse
getprotected set

Generic response that is sent back to the client in abscence of any method generating responses to specific requests.

string IG.Lib.IpcStreamClientServerBase.DefaultStoppedResponse
staticgetset

Default stopped response (sent after the srver has sttopped on request).

string IG.Lib.IpcStreamClientServerBase.StoppedResponse
getprotected set

Stopped response that is sent back to the client after the server stops on its request.

bool IG.Lib.IpcStreamClientServerBase.DefaultIsMultilineResponse
staticget

Default pipe name.

bool IG.Lib.IpcStreamClientServerBase.DefaultIsMultilineRequest
staticget

Default pipe name.

virtual bool IG.Lib.IpcStreamClientServerBase.IsMultilineRequest
getprotected set

Whether or not multi line requests are allowed.

virtual bool IG.Lib.IpcStreamClientServerBase.IsMultilineResponse
getprotected set

Whether or not multi line responses are allowed.


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