mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-18 16:23:28 +02:00
Use wireutil.reply() where possible.
This commit is contained in:
@@ -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')
|
||||
])
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user