UDP Server / Listener

Listens for AES-256 encrypted JSON packets on UDP port 9000 with udp.handle() — only a single UDP listener is supported — and merges the received data into local state with a last-updated timestamp.

udp.handle(9000, function(req){   // listen on port 9000; only a single udp.handle listener is supported
  let data = JSON.parse(req.data); // parse the received payload data as JSON
  for(let i in data){
    if(i === "users"){
      users = data[i];
    } else {
      rem[i] = data[i];
      rem[i]._lu = now();
    }
  }
}, true); // true: use AES-256 encryption

while(run()){
  waitMS(1000);
}