patrickhampson / Apcupsd.NET

A C# implementation of the apcupsd NIS protocol.
MIT License
4 stars 1 forks source link

Remove Thread.Sleep in ApcupsdClient.ExecuteClientAction #1

Open patrickhampson opened 4 years ago

patrickhampson commented 4 years ago

In ApcupsdClient.ExecuteClientAction, I added a Thread.Sleep(20) to handle a case when the buffer does not have enough data to read the next line (in my testing, only seen with the GetEvents call). This can probably be achieved by using a read buffer as the data is being received in chunks.

The NIS protocol (how the APCUPS daemon responds) has the first byte 0x00, second byte is the length of the line, remainder are the line itself, and the line is ended with a newline character. The entire response ends with 0x00 0x00.