/* Send the initial values to a client */ public void sendInitialData(Client aClient) { string buffer = String.Empty; gatherDeviceData(); for (int i = 0; i < mDeviceData.Count; i++) { DeviceDatum value = mDeviceData[i]; if (value.hasInitialValue()) value.append(ref buffer); } if (mBuffer.Count() > 0) { buffer = Utils.GetNowDateTime() + " " + mBuffer + "\n"; Logger.LogMessage(buffer, 3); mServer.sendToClient(aClient, buffer); } }
void removeClient(Client aClient) { Logger.LogMessage("SHDR Client removed" + Convert.ToString(aClient.clNo) + " \n", Logger.DEBUG); mClients.Remove(aClient); }
public void sendToClient(Client aClient, string aString) { if (aClient.DoWrite(aString) < 0) removeClient(aClient); }
void addClient(Client aClient) { mClients.Add(aClient); Logger.LogMessage("SHDR Client Added" + Convert.ToString(aClient.clNo) + " \n", Logger.DEBUG); }
public void ListenForClients() { TcpClient clientSocket = default(TcpClient); int counter = 0; while (bListen) { counter += 1; clientSocket = serverSocket.AcceptTcpClient(); Logger.LogMessage(" >> " + "Client:" + Convert.ToString(counter) + " started!\n", Logger.DEBUG); Client client = new Client(); client.storeClient(clientSocket, Convert.ToString(counter)); _owner.sendInitialData(client); mClients.Add(client); } clientSocket.Close(); serverSocket.Stop(); clientSocket = null; serverSocket = null; }