Reset owner and reverse forwards when a dead worker restarts. This should prevent ghost owners from staying in the device list.

This commit is contained in:
Simo Kinnunen
2015-06-25 17:16:09 +09:00
parent fe7785f003
commit 4a4b0f26d1
5 changed files with 24 additions and 9 deletions

View File

@@ -51,7 +51,7 @@ module.exports = syrup.serial()
, poke: function() {
push.send([
wireutil.global
, wireutil.envelope(new wire.DevicePokeMessage(
, wireutil.envelope(new wire.DeviceReadyMessage(
options.serial
, channel
))

View File

@@ -83,13 +83,15 @@ module.exports = function(options) {
appDealer.send([channel, data])
})
// Worker initialized
.on(wire.DevicePokeMessage, function(channel, message) {
dbapi.setDeviceChannel(message.serial, message.channel)
.on(wire.DeviceReadyMessage, function(channel, message, data) {
dbapi.setDeviceReady(message.serial, message.channel)
.then(function() {
devDealer.send([
message.channel
, wireutil.envelope(new wire.ProbeMessage())
])
appDealer.send([channel, data])
})
})
// Worker messages

View File

@@ -134,6 +134,18 @@ module.exports = function(options) {
}
})
})
.on(wire.DeviceReadyMessage, function(channel, message) {
socket.emit('device.change', {
important: true
, data: {
serial: message.serial
, channel: message.channel
, owner: null // @todo Get rid of need to reset this here.
, ready: true
, reverseForwards: [] // @todo Get rid of need to reset this here.
}
})
})
.on(wire.DevicePresentMessage, function(channel, message) {
socket.emit('device.change', {
important: true
@@ -192,7 +204,6 @@ module.exports = function(options) {
})
.on(wire.DeviceIdentityMessage, function(channel, message) {
datautil.applyData(message)
message.ready = true
socket.emit('device.change', {
important: true
, data: message