From 7bffc0e73848b6315fc8a89277f45668801a674b Mon Sep 17 00:00:00 2001 From: Arjun Roychowdhury Date: Tue, 13 Oct 2015 15:03:42 -0400 Subject: comments updated --- www/js/EventServer.js | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'www/js/EventServer.js') diff --git a/www/js/EventServer.js b/www/js/EventServer.js index 1c7f7c01..4e5f29ef 100644 --- a/www/js/EventServer.js +++ b/www/js/EventServer.js @@ -4,7 +4,10 @@ /* jslint browser: true*/ /* global cordova,StatusBar,angular,console */ -// Websockets + //-------------------------------------------------------------------------- + // This factory interacts with the ZM Event Server + // over websockets and is responsible for rendering real time notifications + //-------------------------------------------------------------------------- angular.module('zmApp.controllers') @@ -14,8 +17,12 @@ angular.module('zmApp.controllers') var ws; + // Display a max of 5 local notifications var localNotificationId=5; + //-------------------------------------------------------------------------- + // Called once at app start. Does a lazy definition of websockets open + //-------------------------------------------------------------------------- function init() { $rootScope.isAlarm = 0; @@ -40,7 +47,7 @@ angular.module('zmApp.controllers') }); - + // Transmit auth information to server ws.$on ('$open', function() { ZMDataModel.zmLog("Websocket open"); ws.$emit('auth', @@ -54,6 +61,7 @@ angular.module('zmApp.controllers') }); + // Handles responses back from ZM ES ws.$on ('$message', function(str) { ZMDataModel.zmLog("Real-time event: " + JSON.stringify(str)); if (str.status != 'Success') @@ -70,14 +78,15 @@ angular.module('zmApp.controllers') var eventsToDisplay=[]; for (var iter=0; iter