From eb332ff36a21afe44dfaf072b39104dfbe789f3e Mon Sep 17 00:00:00 2001 From: Simo Kinnunen Date: Mon, 3 Feb 2014 19:56:01 +0900 Subject: [PATCH] Merge DeviceIdentityMessage on the app side. --- lib/roles/app.js | 3 +++ lib/roles/device.js | 2 +- lib/roles/processor.js | 3 ++- res/app/scripts/services/deviceService.js | 4 ++++ 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/roles/app.js b/lib/roles/app.js index dc866dfd..afb79943 100644 --- a/lib/roles/app.js +++ b/lib/roles/app.js @@ -187,6 +187,9 @@ module.exports = function(options) { .on(wire.DeviceStatusMessage, function(channel, message) { socket.emit('device.status', message) }) + .on(wire.DeviceIdentityMessage, function(channel, message) { + socket.emit('device.identity', message) + }) .handler() // Global messages diff --git a/lib/roles/device.js b/lib/roles/device.js index b58a4736..fe82a73c 100644 --- a/lib/roles/device.js +++ b/lib/roles/device.js @@ -331,7 +331,7 @@ module.exports = function(options) { sub.on('message', wirerouter() .on(wire.ProbeMessage, function(channel, message) { - push.send([channel, + push.send([wireutil.global, wireutil.makeDeviceIdentityMessage(options.serial, identity)]) channels.keepalive(channel) }) diff --git a/lib/roles/processor.js b/lib/roles/processor.js index ed0e6753..aa604fd6 100644 --- a/lib/roles/processor.js +++ b/lib/roles/processor.js @@ -60,8 +60,9 @@ module.exports = function(options) { devDealer.send([message.channel, wireutil.makeProbeMessage()]) }) }) - .on(wire.DeviceIdentityMessage, function(channel, message) { + .on(wire.DeviceIdentityMessage, function(channel, message, data) { dbapi.saveDeviceIdentity(message.serial, message) + appDealer.send([channel, data]) }) .on(wire.ShellCommandDataMessage, function(channel, message, data) { appDealer.send([channel, data]) diff --git a/res/app/scripts/services/deviceService.js b/res/app/scripts/services/deviceService.js index 3fd0c2df..acf37748 100644 --- a/res/app/scripts/services/deviceService.js +++ b/res/app/scripts/services/deviceService.js @@ -47,6 +47,10 @@ define(['./module', 'oboe'], function(mod, oboe) { remove(data) }) + socket.on('device.identity', function(data) { + modify(get(data), data) + }) + oboe('/api/v1/devices') .node('devices[*]', function(device) { // We want to skip other arguments