43 private ManualResetEvent
waitEvent =
new ManualResetEvent(
false);
78 this.commandReceivedEvent += callback;
96 public bool Open(
string hostname)
107 public bool Open(
string hostname,
int port)
129 this.messageReceived = message;
135 if (waitForAcknowledge)
137 waitForAcknowledge =
false;
145 waitForAcknowledge =
false;
147 this.commandReceivedEvent?.Invoke(message, buffer);
158 messageReceived = null;
188 waitForAcknowledge =
true;
199 if (this.messageReceived == null)
208 this.messageReceived = null;
void OnMessageTimeout(object sender, System.Timers.ElapsedEventArgs e)
Callback called by stopwatch on timeout
const int defaultPort
Default server port number
bool Open(string hostname)
Open the specified hostname server, using default port number.
static void Write(string mes)
Write a string to server
Command Manager. Use for timeout managment during reception of data Used as intermediate layer betwee...
delegate void CommandReceivedEvent(string msg, byte[] buffer)
Callback for sending received data to upper level
CommandManagerStatus SendCommand(string cmd, out string answer, double timeout)
Sends a command to TCP server
bool isBusy
flag indicating command manager is currently busy waiting an acknowledge
void OnMessageReception(string message, byte[] buffer)
Callback called by Client class after reception of new message
CommandReceivedEvent commandReceivedEvent
System.Timers.Timer waitTimer
Timer for managing timeout
ManualResetEvent waitEvent
static bool Open(string host)
Open connection to server "host", on default port number.
Static class for TCP client
static void Close()
Close connection to server
CommandManagerStatus
Available status when sending command
static ReadEvent readEvent
bool Open(string hostname, int port)
Open connection to server "host", with port number "port"
string messageReceived
received message
CommandManager(CommandReceivedEvent callback)
Initializes a new instance of the T:monitor.CommandManager class.
~CommandManager()
Releases unmanaged resources and performs other cleanup operations before the T:monitor.CommandManager is reclaimed by garbage collection.
bool waitForAcknowledge
Flag to tell rogram to wait for an acknowledge from server
void Close()
Close connection to server