Properly set up websockets

This commit is contained in:
Andrew Stewart 2013-11-05 10:51:11 -08:00
parent fa53720e17
commit f423758310
2 changed files with 5 additions and 4 deletions

4
dist/api.js vendored
View File

@ -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
});
});

View File

@ -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 }