1
0
Fork 0
mirror of https://github.com/openstf/stf synced 2025-10-06 12:00:08 +02:00

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

@ -19,17 +19,12 @@ module.exports = syrup.serial()
router.on(wire.InstallMessage, function(channel, message) {
log.info('Installing "%s"', message.url)
var seq = 0
var reply = wireutil.reply(options.serial)
function sendProgress(data, progress) {
push.send([
channel
, wireutil.envelope(new wire.TransactionProgressMessage(
options.serial
, seq++
, data
, progress
))
, reply.progress(data, progress)
])
}
@ -124,24 +119,14 @@ module.exports = syrup.serial()
.then(function() {
push.send([
channel
, wireutil.envelope(new wire.TransactionDoneMessage(
options.serial
, seq++
, true
, 'success'
))
, reply.okay('success')
])
})
.catch(function(err) {
log.error('Installation failed', err.stack)
push.send([
channel
, wireutil.envelope(new wire.TransactionDoneMessage(
options.serial
, seq++
, false
, 'fail'
))
, reply.fail('fail')
])
})
})
@ -149,30 +134,20 @@ module.exports = syrup.serial()
router.on(wire.UninstallMessage, function(channel, message) {
log.info('Uninstalling "%s"', message.packageName)
var seq = 0
var reply = wireutil.reply(options.serial)
adb.uninstall(options.serial, message.packageName)
.then(function() {
push.send([
channel
, wireutil.envelope(new wire.TransactionDoneMessage(
options.serial
, seq++
, true
, 'success'
))
, reply.okay('success')
])
})
.catch(function(err) {
log.error('Uninstallation failed', err.stack)
push.send([
channel
, wireutil.envelope(new wire.TransactionDoneMessage(
options.serial
, seq++
, false
, 'fail'
))
, reply.fail('fail')
])
})
})