code: public void run() {
          this.running = true;
  
          while (this.running) {
              DatagramPacket packet = new DatagramPacket(this.buf, this.buf.length);
              try {
                  this.socket.receive(packet);
              } catch (IOException ignored) {
                  continue;
              }
  
              byte[] worker = new byte[2];
              System.arraycopy(this.buf, 2, worker, 0, 2);
              int length = (int)ByteArray.fromBytes(worker);
              worker = new byte[length];
              System.arraycopy(this.buf, 0, worker, 0, length);
              Command msg = new Command(worker, tk);
              InetAddress address = packet.getAddress();
              int port = packet.getPort();
              int timeStamp = (int)(System.currentTimeMillis() / 1000L);
              Response resp;
              if (msg.isHello()){
                  resp = new Response(this.tk, this.deviceId, timeStamp);
              } else {
                  if (msg.getDeviceID() != this.deviceId) continue;
                  Object data = executeCommand(msg.getMethod(),msg.getParams());
                  if (data == null){
                      data = "unknown_method";
                  }
                  resp = new Response(this.tk, this.deviceId, timeStamp, msg.getPayloadID(), data);
              }
              byte[] respMsg = resp.create();
              System.arraycopy(respMsg,0,this.buf,0,respMsg.length);
              packet = new DatagramPacket(buf, respMsg.length, address, port);
  
              try {
                  this.socket.send(packet);
              } catch (IOException ignored) {
              }
          }
          this.socket.close();
      }
docs: Start the de.sg_o.app.miio.server.