var Comm = { created: false, customMgr : {}, deviceInstance : [] }; Comm.init = function () { if (this.created == true) { return; } this.created = true; // >> Register custom manager callback to receive device connect and disconnect events if (Config.deviceType != 0) return; try { Comm.customMgr = webapis.customdevice || {}; Comm.customMgr.registerManagerCallback(Comm.onDeviceStatusChange); // >> Initializes custom device profile and gets available devices Comm.customMgr.getCustomDevices(Comm.onCustomObtained); } catch (e) { } Main.log("curWidget.id= " + curWidget.id); Main.logToServer("curWidget.id= (" + curWidget.id+")"); }; //TODO: I should ensure that I take only events from the selected VDR server Comm.onDeviceStatusChange = function (sParam) { switch( Number(sParam.eventType) ) { case Comm.customMgr.MGR_EVENT_DEV_CONNECT: Main.logToServer("onDeviceStatusChange - MGR_EVENT_DEV_CONNECT: name= " + sParam.name + " type= " +sParam.deviceType); break; case Comm.customMgr.MGR_EVENT_DEV_DISCONNECT: Main.logToServer("onDeviceStatusChange - MGR_EVENT_DEV_DISCONNECT: name= " + sParam.name + " type= " +sParam.deviceType); break; default: Main.logToServer("onDeviceStatusChange - Unknown event eType= " + sParam.eventType + " name= " + sParam.name+ " dType= "+sParam.deviceType); break; } Comm.customMgr.getCustomDevices(Comm.onCustomObtained); }; Comm.onCustomObtained = function (customs) { // Main.logToServer("onCustomObtained - found " + customs.length + " custom device(s)"); for(var i=0; i