mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-19 08:53:30 +02:00
Use wireutil.reply() where possible.
This commit is contained in:
@@ -68,63 +68,43 @@ module.exports = syrup.serial()
|
||||
|
||||
router
|
||||
.on(wire.GroupMessage, function(channel, message) {
|
||||
var seq = 0
|
||||
var reply = wireutil.reply(options.serial)
|
||||
if (devutil.matchesRequirements(identity, message.requirements)) {
|
||||
if (!isGrouped()) {
|
||||
joinGroup(message.owner, message.timeout)
|
||||
push.send([
|
||||
channel
|
||||
, wireutil.envelope(new wire.TransactionDoneMessage(
|
||||
options.serial
|
||||
, seq++
|
||||
, true
|
||||
))
|
||||
, reply.okay()
|
||||
])
|
||||
}
|
||||
else if (isOwnedBy(message.owner)) {
|
||||
push.send([
|
||||
channel
|
||||
, wireutil.envelope(new wire.TransactionDoneMessage(
|
||||
options.serial
|
||||
, seq++
|
||||
, true
|
||||
))
|
||||
, reply.okay()
|
||||
])
|
||||
}
|
||||
else {
|
||||
push.send([
|
||||
channel
|
||||
, wireutil.envelope(new wire.TransactionDoneMessage(
|
||||
options.serial
|
||||
, seq++
|
||||
, false
|
||||
))
|
||||
, reply.fail()
|
||||
])
|
||||
}
|
||||
}
|
||||
})
|
||||
.on(wire.UngroupMessage, function(channel, message) {
|
||||
var seq = 0
|
||||
var reply = wireutil.reply(options.serial)
|
||||
if (devutil.matchesRequirements(identity, message.requirements)) {
|
||||
if (isGrouped()) {
|
||||
leaveGroup()
|
||||
push.send([
|
||||
channel
|
||||
, wireutil.envelope(new wire.TransactionDoneMessage(
|
||||
options.serial
|
||||
, seq++
|
||||
, true
|
||||
))
|
||||
, reply.okay()
|
||||
])
|
||||
}
|
||||
else {
|
||||
push.send([
|
||||
channel
|
||||
, wireutil.envelope(new wire.TransactionDoneMessage(
|
||||
options.serial
|
||||
, seq++
|
||||
, true
|
||||
))
|
||||
, reply.okay()
|
||||
])
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user