Example #1
0
        /* 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);
            }
        }
Example #2
0
 void removeClient(Client aClient)
 {
     Logger.LogMessage("SHDR Client removed" + Convert.ToString(aClient.clNo) + " \n", Logger.DEBUG);
     mClients.Remove(aClient);
 }
Example #3
0
 public void sendToClient(Client aClient, string aString)
 {
     if (aClient.DoWrite(aString) < 0)
         removeClient(aClient);
 }
Example #4
0
 void addClient(Client aClient)
 {
     mClients.Add(aClient);
     Logger.LogMessage("SHDR Client Added" + Convert.ToString(aClient.clNo) + " \n", Logger.DEBUG);
 }
Example #5
0
        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;
        }