1
0
Fork 0
mirror of https://github.com/openstf/stf synced 2025-10-04 18:29:17 +02:00

Tell the UI why the device became unusable.

This commit is contained in:
Simo Kinnunen 2014-07-23 17:58:08 +09:00
parent d8dec38cad
commit 0ec8082ac1
3 changed files with 10 additions and 4 deletions

View file

@ -72,7 +72,7 @@ module.exports = syrup.serial()
}
}
plugin.leave = function() {
plugin.leave = function(reason) {
return plugin.get()
.then(function(group) {
log.important('No longer owned by "%s"', group.email)
@ -86,6 +86,7 @@ module.exports = syrup.serial()
, wireutil.envelope(new wire.LeaveGroupMessage(
options.serial
, group
, reason
))
])
@ -136,7 +137,7 @@ module.exports = syrup.serial()
var reply = wireutil.reply(options.serial)
grouputil.match(ident, message.requirements)
.then(function() {
return plugin.leave()
return plugin.leave('ungroup_request')
})
.then(function() {
push.send([
@ -154,12 +155,12 @@ module.exports = syrup.serial()
channels.on('timeout', function(channel) {
if (currentGroup && channel === currentGroup.group) {
plugin.leave()
plugin.leave('automatic_timeout')
}
})
lifecycle.observe(function() {
return plugin.leave()
return plugin.leave('lifecycle_ended')
.catch(grouputil.NoGroupError, function() {
return true
})

View file

@ -130,6 +130,7 @@ module.exports = function(options) {
, ready: false
, lastHeartbeatAt: null
, using: false
, likelyLeaveReason: 'device_absent'
}
})
})
@ -139,6 +140,7 @@ module.exports = function(options) {
, data: datautil.applyOwner({
serial: message.serial
, owner: message.owner
, likelyLeaveReason: 'owner_change'
}
, user
)
@ -150,12 +152,14 @@ module.exports = function(options) {
, data: datautil.applyOwner({
serial: message.serial
, owner: null
, likelyLeaveReason: message.reason
}
, user
)
})
})
.on(wire.DeviceStatusMessage, function(channel, message) {
message.likelyLeaveReason = 'status_change'
socket.emit('device.change', {
important: true
, data: message

View file

@ -236,6 +236,7 @@ message JoinGroupMessage {
message LeaveGroupMessage {
required string serial = 1;
required OwnerMessage owner = 2;
required string reason = 3;
}
// Input