Sha256: 85c6cab2afeae51025d64c1fa49fb4438d1c46a2c2aaeb90cc823641a3f0e1a3
Contents?: true
Size: 1017 Bytes
Versions: 2
Compression:
Stored size: 1017 Bytes
Contents
var DeviceEventsCtrl = function DeviceEventsCtrl($scope, $filter) { $scope.listen = function() { if ($scope.eventName === "") { return; } if ($scope.device.events == null) { $scope.device.events = []; } if ($scope.device.listeners == null) { $scope.device.listeners = {}; } var robot = $scope.robot.name, device = $scope.device.name, event = $scope.eventName; var uri = "/robots/" + robot + "/devices/" + device + "/events/" + event; var $device = $scope.device; var source = new EventSource(uri); source.addEventListener('message', function(message) { $scope.$apply(function() { if ($device.events.length > 4) { $device.events.pop(); } $device.events.unshift({ name: event, data: JSON.parse(message.data) }); }); }, false); $scope.device.listeners[event] = source; $scope.eventName = ""; }; $scope.remove = function(name) { $scope.device.listeners[name].close(); delete $scope.device.listeners[name]; }; }
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
robeaux-0.1.1 | js/controllers/device_events_ctrl.js |
robeaux-0.1.0 | js/controllers/device_events_ctrl.js |