From f423758310ba8ad081e6d06f6abd518be2786d10 Mon Sep 17 00:00:00 2001 From: Andrew Stewart Date: Tue, 5 Nov 2013 10:51:11 -0800 Subject: [PATCH] Properly set up websockets --- dist/api.js | 4 ++-- src/api.coffee | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/dist/api.js b/dist/api.js index 00c6b86..3d6d406 100644 --- a/dist/api.js +++ b/dist/api.js @@ -122,10 +122,10 @@ _ref = [req.params.robotid, req.params.deviceid], robotid = _ref[0], deviceid = _ref[1]; return master.findRobotDevice(robotid, deviceid, function(err, device) { if (err) { - res.io.respond(err); + req.io.respond(err); } return device.on('update', function(data) { - return res.io.respond({ + return req.io.emit('update', { data: data }); }); diff --git a/src/api.coffee b/src/api.coffee index c7dedeb..674b6dd 100644 --- a/src/api.coffee +++ b/src/api.coffee @@ -86,5 +86,6 @@ namespace "Api", -> [robotid, deviceid] = [req.params.robotid, req.params.deviceid] master.findRobotDevice robotid, deviceid, (err, device) -> - res.io.respond(err) if err - device.on 'update', (data) -> res.io.respond { data: data } + req.io.respond(err) if err + device.on 'update', (data) -> + req.io.emit 'update', { data: data }