22 private ManualResetEvent
waitEvent =
new ManualResetEvent(
false);
57 this.commandReceivedEvent += callback;
75 public bool Open(
string hostname)
86 public bool Open(
string hostname,
int port)
108 this.messageReceived = message;
114 if (waitForAcknowledge)
116 waitForAcknowledge =
false;
124 waitForAcknowledge =
false;
126 this.commandReceivedEvent?.Invoke(message, buffer);
137 messageReceived = null;
165 waitForAcknowledge =
true;
172 if (this.messageReceived == null)
180 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