12 using System.Net.Sockets;
14 using System.Text.RegularExpressions;
83 #endregion Constructors 85 #region Outgoing Message Methods 111 #endregion Outgoing Message Methods 113 #region Incoming Message Methods 150 #endregion Incoming Message Methods 152 #region Connected Object Methods 161 Socket.Shutdown(SocketShutdown.Both);
172 return Socket.RemoteEndPoint.ToString();
195 #endregion Connected Object Methods 197 #region Sensor Data Processing 211 foreach (
string word
in words)
213 if (count == 0) {
status = word; }
227 Console.Write(
location +
"," +
status +
"," +
temperature +
"," +
humidity + DateTime.Now.ToString(
" HH:mm:ss") +
"," + DateTime.Now.ToString(
"yyyy-MM-dd") + Environment.NewLine);
239 #endregion Sensor Data Processing int IncomingMessageLength()
Gets the length of the incoming message
void CreateOutgoingMessage(string msg)
Creates a new outgoing message
void parseData(string data)
void BuildIncomingMessage(int bytesRead)
Converts the buffer to a string ans stores it
static string temperatureBuffer
void ClearIncomingMessage()
Clears the current incoming message so that we can start building for the next message
static void SaveErrorData(string error)
Log all the error that occurs in the program
string MessageTerminator
void Close()
Closes the connection
static string presenseData
static void EncryptData(string SensorData)
This method encrypts the sensor data
StringBuilder OutgoingMessage
string GetRemoteEndPoint()
static string temperature
byte [] OutgoingMessageToBytes()
Converts the outgoing message to bytes
StringBuilder IncomingMessage
void PrintMessage()
Print the details of the current incoming message
static string humidityBuffer
bool MessageReceived()
Determines if the message was fully received