summaryrefslogtreecommitdiffstats
path: root/server/lib/wolhelper.js
blob: e9cb3b08c466f0dd5e501d3a590efc8b4b1037ec (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
const wol = require('node-wol')

function wakeUp (clients) {
  let i = 0
  const loop = () => {
    setTimeout(() => {
      let client = clients[i]
      console.log('Waking up: ' + client.name + ' (' + client.mac + ')')
      wol.wake(client.mac, { address: client.ip.slice(0, client.ip.lastIndexOf('.') + 1) + '255' }, err => { if (err) console.log(err) })
      i++
      if (i < clients.length) loop()
    }, 10)
  }
  loop()
}

module.exports = { wakeUp }