Use wireutil.reply() where possible.

This commit is contained in:
Simo Kinnunen
2014-04-11 14:54:19 +09:00
parent 90b39306a8
commit 7f74ecd7af
8 changed files with 32 additions and 128 deletions

View File

@@ -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)
])
})
})