mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-18 08:03:30 +02:00
In-memory reaper. TtlSet needs tests.
This commit is contained in:
24
lib/units/device/plugins/heartbeat.js
Normal file
24
lib/units/device/plugins/heartbeat.js
Normal file
@@ -0,0 +1,24 @@
|
||||
var syrup = require('stf-syrup')
|
||||
|
||||
var lifecycle = require('../../../util/lifecycle')
|
||||
var wire = require('../../../wire')
|
||||
var wireutil = require('../../../wire/util')
|
||||
|
||||
module.exports = syrup.serial()
|
||||
.dependency(require('../support/push'))
|
||||
.define(function(options, push) {
|
||||
function beat() {
|
||||
push.send([
|
||||
wireutil.global
|
||||
, wireutil.envelope(new wire.DeviceHeartbeatMessage(
|
||||
options.serial
|
||||
))
|
||||
])
|
||||
}
|
||||
|
||||
var timer = setInterval(beat, options.heartbeatInterval)
|
||||
|
||||
lifecycle.observe(function() {
|
||||
clearInterval(timer)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user