mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-18 16:13:24 +02:00
Use wireutil.reply() where possible.
This commit is contained in:
@@ -13,57 +13,38 @@ module.exports = syrup.serial()
|
||||
|
||||
router.on(wire.PasteMessage, function(channel, message) {
|
||||
log.info('Pasting "%s" to clipboard', message.text)
|
||||
var seq = 0
|
||||
var reply = wireutil.reply(options.serial)
|
||||
input.paste(message.text)
|
||||
.then(function() {
|
||||
push.send([
|
||||
channel
|
||||
, wireutil.envelope(new wire.TransactionDoneMessage(
|
||||
options.serial
|
||||
, seq++
|
||||
, true
|
||||
))
|
||||
, reply.okay()
|
||||
])
|
||||
})
|
||||
.catch(function(err) {
|
||||
log.error('Paste failed', err.stack)
|
||||
push.send([
|
||||
channel
|
||||
, wireutil.envelope(new wire.TransactionDoneMessage(
|
||||
options.serial
|
||||
, seq++
|
||||
, false
|
||||
, err.message
|
||||
))
|
||||
, reply.fail(err.message)
|
||||
])
|
||||
})
|
||||
})
|
||||
|
||||
router.on(wire.CopyMessage, function(channel) {
|
||||
log.info('Copying clipboard contents')
|
||||
var seq = 0
|
||||
var reply = wireutil.reply(options.serial)
|
||||
input.copy()
|
||||
.then(function(content) {
|
||||
push.send([
|
||||
channel
|
||||
, wireutil.envelope(new wire.TransactionDoneMessage(
|
||||
options.serial
|
||||
, seq++
|
||||
, true
|
||||
, content
|
||||
))
|
||||
, reply.okay(content)
|
||||
])
|
||||
})
|
||||
.catch(function(err) {
|
||||
log.error('Copy failed', 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