void sendWattUsageUpdate(short socketid, int watt)
 {
     scPacket pck = new scPacket(PACKET_TYPE.S_SOCKET_POWER_UPDATE);
     pck.writeShort(socketid);
     pck.writeLong(watt);
     Program.getRoot().sendToAll(pck);
 }
 void sendSocketPowerInfo(short socketid)
 {
     List<relay> relays = Program.getRoot().getRelays();
     for (int i = 0; i < relays.Count; i++)
     {
         if (relays[i].getID() == socketid)
         {
             scPacket pck = new scPacket(PACKET_TYPE.S_SOCKET_POWER_INFO);
             pck.writeShort(socketid);
             byte state = (byte)(relays[i].getCurrentState() == relay.RELAY_STATE.ON ? 1 : 0);
             pck.writeByte(state);
             pck.writeLong(relays[i].getTotalUptime());
             pck.writeLong(relays[i].getDailyUptime());
             pck.writeLong(relays[i].getDailyDowntime());
             pck.writeLong(relays[i].getWatt());
             sendPacket(pck);
             break;
         }
     }
 }
 void sendSockUpdateToAll(short sockid, byte state)
 {
     scPacket pck = new scPacket(PACKET_TYPE.S_SOCKET_UPDATE);
     pck.writeShort(sockid);
     pck.writeByte(state);
     Program.getRoot().sendToAll(pck);
 }
 void sendOnlineSockets()
 {
     scPacket pck = new scPacket(PACKET_TYPE.S_SEND_ONLINE_CLIENTS);
     // now write all the data needed to the packet
     List<relay> relays = Program.getRoot().getRelays();
     pck.writeShort((short)relays.Count);
     for (int i = 0; i < relays.Count; i++)
     {
         pck.writeShort(relays[i].getID());                  //2
         pck.writeByte((byte)relays[i].getCurrentState());   //3
         pck.writeLong(relays[i].getTotalUptime());          //7
         pck.writeLong(relays[i].getDailyUptime());          //11
         pck.writeLong(relays[i].getDailyDowntime());        //15
         pck.writeLong(relays[i].getWatt());                 //19
     }
     sendPacket(pck);
 }