mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-19 05:53:27 +02:00
Use wireutil.reply() where possible.
This commit is contained in:
@@ -14,7 +14,7 @@ module.exports = syrup.serial()
|
||||
var log = logger.createLogger('device:plugins:shell')
|
||||
|
||||
router.on(wire.ShellCommandMessage, function(channel, message) {
|
||||
var seq = 0
|
||||
var reply = wireutil.reply(options.serial)
|
||||
|
||||
log.info('Running shell command "%s"', message.command)
|
||||
|
||||
@@ -34,11 +34,7 @@ module.exports = syrup.serial()
|
||||
while ((chunk = stream.read())) {
|
||||
push.send([
|
||||
channel
|
||||
, wireutil.envelope(new wire.TransactionProgressMessage(
|
||||
options.serial
|
||||
, seq++
|
||||
, chunk
|
||||
))
|
||||
, reply.progress(chunk)
|
||||
])
|
||||
}
|
||||
}
|
||||
@@ -46,11 +42,7 @@ module.exports = syrup.serial()
|
||||
function endListener() {
|
||||
push.send([
|
||||
channel
|
||||
, wireutil.envelope(new wire.TransactionDoneMessage(
|
||||
options.serial
|
||||
, seq++
|
||||
, true
|
||||
))
|
||||
, reply.okay()
|
||||
])
|
||||
resolver.resolve()
|
||||
}
|
||||
@@ -85,12 +77,7 @@ module.exports = syrup.serial()
|
||||
log.error('Shell command "%s" failed', message.command, err.stack)
|
||||
push.send([
|
||||
channel
|
||||
, wireutil.envelope(new wire.TransactionDoneMessage(
|
||||
options.serial
|
||||
, seq++
|
||||
, false
|
||||
, err.message
|
||||
))
|
||||
, reply.fail(err.message)
|
||||
])
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user