diff --git a/dist/angular-rtcomm.js b/dist/angular-rtcomm.js index 15fed9f..4a85458 100644 --- a/dist/angular-rtcomm.js +++ b/dist/angular-rtcomm.js @@ -14,7 +14,7 @@ * limitations under the License. * * Angular module for Rtcomm - * @version v1.0.3 - 2015-12-07 + * @version v1.0.3 - 2016-02-18 * @link https://github.com/WASdev/lib.angular-rtcomm * @author Brian Pulito (https://github.com/bpulito) */ @@ -94,6 +94,7 @@ var rtcommDebug = "DEBUG"; var ringtone = null; var ringbacktone = null; + var trickleICE = true; var setConfig = function(config){ providerConfig.server = (typeof config.server !== "undefined")? config.server : providerConfig.server; @@ -111,9 +112,10 @@ broadcastAudio = (typeof config.broadcastAudio !== "undefined")? config.broadcastAudio: broadcastAudio; broadcastVideo = (typeof config.broadcastVideo !== "undefined")? config.broadcastVideo: broadcastVideo; + trickleICE = (typeof config.trickleICE !== "undefined")? config.trickleICE: trickleICE; - ringbacktone = (typeof config.ringbacktone !== "undefined")? config.ringbacktone: null; - ringtone = (typeof config.ringtone !== "undefined")? config.ringtone : null; + ringbacktone = (typeof config.ringbacktone !== "undefined")? config.ringbacktone: ringbacktone; + ringtone = (typeof config.ringtone !== "undefined")? config.ringtone : ringtone; rtcommDebug = (typeof config.rtcommDebug !== "undefined")? config.rtcommDebug: rtcommDebug; @@ -145,7 +147,9 @@ getRtcommDebug: function(){return rtcommDebug;}, - isRtcommDisabled : function(){return _disableRtcomm;} + isRtcommDisabled : function(){return _disableRtcomm;}, + + getTrickleICE: function(){return trickleICE;} }; }; @@ -179,9 +183,12 @@ var mediaConfig = { ringbacktone: RtcommConfigService.getRingBackTone(), ringtone: RtcommConfigService.getRingTone(), - broadcast : { - audio : RtcommConfigService.getBroadcastAudio(), - video : RtcommConfigService.getBroadcastVideo() + webrtcConfig: { + broadcast : { + audio : RtcommConfigService.getBroadcastAudio(), + video : RtcommConfigService.getBroadcastVideo() + }, + trickleICE: RtcommConfigService.getTrickleICE() }, webrtc : RtcommConfigService.getWebRTCEnabled(), chat : RtcommConfigService.getChatEnabled(), @@ -191,7 +198,8 @@ }; myEndpointProvider.on('reset', function(event_object) { - // Should have a reason. + //The Endpoint provider is destroyed on reset + endpointProviderInitialized = false; _alert({type:'danger', msg: event_object.reason}); }); @@ -304,6 +312,8 @@ }, + 'session:connecting' : callback, + // These are all the WebRTC related events. 'webrtc:connected' : function(eventObject) { $log.debug('<<------rtcomm-service------>> - Event: ' + eventObject.eventName + ' remoteEndpointID: ' + eventObject.endpoint.getRemoteEndpointID()); @@ -467,7 +477,9 @@ for (var index = 0; index < sessions.length; index++) { if(sessions[index].endpointUUID === endpointUUID){ - _getEndpoint(endpointUUID).destroy(); + var endpoint = _getEndpoint(endpointUUID); + if(typeof endpoint !== 'undefined') + endpoint.destroy(); // Remove the disconnected endpoint from the list. sessions.splice(index, 1); @@ -897,7 +909,7 @@ angular .module('angular-rtcomm-ui', [ - 'ui.bootstrap', + 'ui.bootstrap', 'angular-rtcomm-service']) .directive('rtcommSessionManager', rtcommSessionManager) .directive('rtcommRegister', rtcommRegister) @@ -987,14 +999,14 @@ function rtcommRegister(RtcommService, $log) { controller: ["$scope", function ($scope) { $scope.nextAction = 'Register'; - + $scope.reguserid = ''; - + $scope.invalid = false; var invalidCharacters = /(\$|#|\+|\/|\\)+/i; //Invalid characters for MQTT Topic Path - - //Watch for changes in reguserid + + //Watch for changes in reguserid $scope.$watch('reguserid', function(){ if($scope.reguserid.length < 1 || invalidCharacters.test($scope.reguserid)){ @@ -1252,6 +1264,15 @@ function rtcommEndpointStatus(RtcommService, $log){ } }); + $scope.$on('session:connecting', function (event, eventObject) { + $log.debug('session:connecting received: endpointID = ' + eventObject.endpoint.id); + // if ($scope.epCtrlActiveEndpointUUID != eventObject.endpoint.id){ + $scope.sessionState = 'session:connecting'; + $scope.epCtrlRemoteEndpointID = eventObject.endpoint.getRemoteEndpointID(); + // } + }); + + $scope.$on('session:queued', function (event, eventObject) { $log.debug('session:queued received: endpointID = ' + eventObject.endpoint.id); if ($scope.epCtrlActiveEndpointUUID == eventObject.endpoint.id){ @@ -1288,7 +1309,12 @@ function rtcommEndpointStatus(RtcommService, $log){ }); $scope.$on('rtcomm::init', function(event, success, details){ - + if(success === true){ + $scope.epCtrlActiveEndpointUUID = RtcommService.getActiveEndpoint(); + $scope.epCtrlRemoteEndpointID = RtcommService.getRemoteEndpoint($scope.epCtrlActiveEndpointUUID); + $scope.sessionState = RtcommService.getSessionState($scope.epCtrlActiveEndpointUUID); + $scope.failureReason = ''; + } if(success == false){ $scope.sessionState = 'session:stopped'; $scope.epCtrlRemoteEndpointID = null; @@ -1391,7 +1417,7 @@ function rtcommChat(RtcommService, $log) { //In this else, a notification could be sent } },true); - } + } else { $log.warn('chatPanel not found: most likely you need to load jquery prior to angular'); } @@ -1963,7 +1989,7 @@ angular.module('angular-rtcomm-ui').run(['$templateCache', function($templateCac $templateCache.put('templates/rtcomm/rtcomm-endpoint-status.html', - "

Connected to {{epCtrlRemoteEndpointID}} No active sessions, waiting... Inbound call from {{epCtrlRemoteEndpointID}} Attempting to call {{epCtrlRemoteEndpointID}} Call to {{epCtrlRemoteEndpointID}} is ringing Waiting in queue at: {{queueCount}} Call failed with reason: {{failureReason}}

" + "

Connected to {{epCtrlRemoteEndpointID}} No active sessions, waiting... Inbound call from {{epCtrlRemoteEndpointID}} Attempting to call {{epCtrlRemoteEndpointID}} Call to {{epCtrlRemoteEndpointID}} is ringing Waiting in queue at: {{queueCount}} Call failed with reason: {{failureReason}} Connecting to {{epCtrlRemoteEndpointID}} ...

" ); diff --git a/dist/angular-rtcomm.min.js b/dist/angular-rtcomm.min.js index 7243f0c..a888892 100644 --- a/dist/angular-rtcomm.min.js +++ b/dist/angular-rtcomm.min.js @@ -14,9 +14,9 @@ * limitations under the License. * * Angular module for Rtcomm - * @version v1.0.3 - 2015-12-07 + * @version v1.0.3 - 2016-02-18 * @link https://github.com/WASdev/lib.angular-rtcomm * @author Brian Pulito (https://github.com/bpulito) */ -!function(){angular.module("angular-rtcomm",["ui.bootstrap","treeControl","angular-rtcomm-ui","angular-rtcomm-presence","angular-rtcomm-service"])}(),function(){function a(a,b){b.debug("RtcommConfigService: Abs URL: "+a.absUrl());var c=a.search().disableRtcomm;c="undefined"==typeof c||null===c?!1:"true"===c?!0:!1,b.debug("RtcommConfigService: _disableRtcomm = "+c);var d={server:a.host(),port:a.port(),rtcommTopicPath:"/rtcomm/",createEndpoint:!1,appContext:"default",userid:"",presence:{topic:""}};b.debug("providerConfig.server: "+d.server),b.debug("providerConfig.port: "+d.port);var e={chat:!0,webrtc:!0},f=!0,g=!0,h="DEBUG",i=null,j=null,k=function(a){d.server="undefined"!=typeof a.server?a.server:d.server,d.port="undefined"!=typeof a.port?a.port:d.port,d.rtcommTopicPath="undefined"!=typeof a.rtcommTopicPath?a.rtcommTopicPath:d.rtcommTopicPath,d.createEndpoint="undefined"!=typeof a.createEndpoint?a.createEndpoint:d.createEndpoint,d.appContext="undefined"!=typeof a.appContext?a.appContext:d.appContext,d.presence.topic="undefined"!=typeof a.presenceTopic?a.presenceTopic:d.presence.topic,e.chat="undefined"!=typeof a.chat?a.chat:e.chat,e.webrtc="undefined"!=typeof a.webrtc?a.webrtc:e.webrtc,f="undefined"!=typeof a.broadcastAudio?a.broadcastAudio:f,g="undefined"!=typeof a.broadcastVideo?a.broadcastVideo:g,j="undefined"!=typeof a.ringbacktone?a.ringbacktone:null,i="undefined"!=typeof a.ringtone?a.ringtone:null,h="undefined"!=typeof a.rtcommDebug?a.rtcommDebug:h,b.debug("rtcommDebug from config is: "+a.rtcommDebug),"undefined"!=typeof a.userid&&(d.userid=a.userid),b.debug("providerConfig is now: ",d)};return{setProviderConfig:function(a){k(a)},getProviderConfig:function(){return d},getWebRTCEnabled:function(){return e.webrtc},getChatEnabled:function(){return e.chat},getBroadcastAudio:function(){return f},getBroadcastVideo:function(){return g},getRingTone:function(){return i},getRingBackTone:function(){return j},getRtcommDebug:function(){return h},isRtcommDisabled:function(){return c}}}function b(a,b,c,d){var e=new rtcomm.EndpointProvider,f=!1,g=null,h=[],i=null,j=!1,k="selfView",l="remoteView";e.setLogLevel(d.getRtcommDebug()),b.debug("rtcomm-service - endpointProvider log level is: "+e.getLogLevel()),b.debug("rtcomm-service - endpointProvider log level should be: "+d.getRtcommDebug()),e.setAppContext(d.getProviderConfig().appContext);var m=function(){return null==i&&(i={state:"available",userDefines:[]}),i},n=function(){var a={ringbacktone:d.getRingBackTone(),ringtone:d.getRingTone(),broadcast:{audio:d.getBroadcastAudio(),video:d.getBroadcastVideo()},webrtc:d.getWebRTCEnabled(),chat:d.getChatEnabled()};return a};e.on("reset",function(a){x({type:"danger",msg:a.reason})}),e.on("queueupdate",function(c){b.debug("<<------rtcomm-service------>> - Event: queueupdate"),b.debug("queueupdate",c),a.$evalAsync(function(){a.$broadcast("queueupdate",c)})}),e.on("newendpoint",function(c){b.debug("<<------rtcomm-service------>> - Event: newendpoint remoteEndpointID: "+c.getRemoteEndpointID()),c.on("onetimemessage",function(c){if(b.debug("<<------rtcomm-onetimemessage------>> - Event: ",c),"undefined"!=c.onetimemessage.type&&"iFrameURL"==c.onetimemessage.type){var d=s(c.endpoint.id);d.iFrameURL=c.onetimemessage.iFrameURL,a.$evalAsync(function(){a.$broadcast("rtcomm::iframeUpdate",c.endpoint.id,c.onetimemessage.iFrameURL)})}}),a.$evalAsync(function(){a.$broadcast("newendpoint",c)})});var o=function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){if(c.eventName.indexOf("session:")>-1){var b=s(c.endpoint.id);b.sessionState=c.eventName}a.$broadcast(c.eventName,c)}),1==j&&a.$digest()};e.setRtcommEndpointConfig({ringtone:d.getRingTone(),ringbacktone:d.getRingBackTone(),"session:started":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){var b=s(c.endpoint.id);v(c.endpoint.id),b.sessionStarted=!0,b.remoteEndpointID=c.endpoint.getRemoteEndpointID(),a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},"session:alerting":o,"session:trying":o,"session:ringing":o,"session:queued":o,"session:failed":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){t(c.endpoint.id),a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},"session:stopped":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){t(c.endpoint.id),a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},"webrtc:connected":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){s(c.endpoint.id).webrtcConnected=!0,a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},"webrtc:remotemuted":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},"webrtc:disconnected":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){var b=r(c.endpoint.id);null!=b&&(b.webrtcConnected=!1),a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},"chat:connected":o,"chat:disconnected":o,"chat:message":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){var b={time:new Date,name:c.message.from,message:angular.copy(c.message.message)};s(c.endpoint.id).chats.push(b),a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},destroyed:o});var p=function(c){b.debug("<<------rtcomm-service------>> - Event: Provider init succeeded"),null!=i&&(b.debug("RtcommService: initSuccess: updating presence record"),e.publishPresence(i)),a.$evalAsync(function(){var b={ready:c.ready,registered:c.registered,endpoint:c.endpoint,userid:d.getProviderConfig().userid};a.$broadcast("rtcomm::init",!0,b)}),1==j&&a.$digest()},q=function(c){b.debug("<<------rtcomm-service------>> - Event: Provider init failed: error: ",c),a.$evalAsync(function(){a.$broadcast("rtcomm::init",!1,c)}),1==j&&a.$digest()},r=function(a){for(var b=null,c=0;c> - Event: ",c),"undefined"!=c.onetimemessage.type&&"iFrameURL"==c.onetimemessage.type){var d=s(c.endpoint.id);d.iFrameURL=c.onetimemessage.iFrameURL,a.$evalAsync(function(){a.$broadcast("rtcomm::iframeUpdate",c.endpoint.id,c.onetimemessage.iFrameURL)})}})):d=e.getRtcommEndpoint(c),d},v=function(b){var c=w();if(null!=c&&c!=b){var d=r(c);null!=d&&(d.activated=!1)}var d=s(b);d.activated=!0,a.$broadcast("endpointActivated",b)},w=function(){for(var a=null,b=0;b-1&&c.chat.enable(),b.indexOf("webrtc")>-1){var d=!0;b.indexOf("disableTrickleICE")>-1&&(d=!1),c.webrtc.enable({trickleICE:d})}return v(c.id),c.connect(a),c.id},getSessions:function(){return h},endCall:function(a){a.disconnect()},setActiveEndpoint:function(a){v(a)},getActiveEndpoint:function(){return w()},getRemoteEndpoint:function(a){var b=null;if(null!=a){var c=r(a);null!=c&&(b=c.remoteEndpointID)}return b},setDefaultViewSelector:function(){k="selfView",l="remoteView"},setViewSelector:function(a,b){k=a,l=b},setVideoView:function(a){b.debug("rtcommVideo: setting local media");var c=null;"undefined"!=typeof a&&null!=a?c=u(a):null!=w()&&(c=u(w())),null!=c&&c.webrtc.setLocalMedia({mediaOut:document.querySelector("#"+k),mediaIn:document.querySelector("#"+l)})}}}angular.module("angular-rtcomm-service",[]).config(["$logProvider",function(a){a.debugEnabled(!0)}]).factory("RtcommConfigService",a).factory("RtcommService",b),a.$inject=["$location","$log","$window"],b.$inject=["$rootScope","$log","$http","RtcommConfigService"]}(),function(){function a(a,b){return{restrict:"E",templateUrl:"templates/rtcomm/rtcomm-sessionmgr.html",controller:["$scope",function(c){c.sessions=a.getSessions(),c.sessMgrActiveEndpointUUID=a.getActiveEndpoint(),c.publishPresence=!1,c.sessionPresenceData=[],c.init=function(a){c.publishPresence=a,c.updatePresence()},c.$on("endpointActivated",function(a,d){b.debug("rtcommSessionmgr: endpointActivated ="+d),c.sessMgrActiveEndpointUUID=d}),c.$on("session:started",function(a,d){b.debug("rtcommSessionmgr: session:started: uuid ="+d.endpoint.id),c.updatePresence()}),c.activateSession=function(d){b.debug("rtcommSessionmgr: activateEndpoint ="+d),c.sessMgrActiveEndpointUUID!=d&&a.setActiveEndpoint(d)},c.updatePresence=function(){1==c.publishPresence&&(a.removeFromPresenceRecord(c.sessionPresenceData,!1),c.sessionPresenceData=[{name:"sessions",value:String(c.sessions.length)}],a.addToPresenceRecord(c.sessionPresenceData))}}],controllerAs:"sessionmgr"}}function b(a,b){return{restrict:"E",templateUrl:"templates/rtcomm/rtcomm-register.html",controller:["$scope",function(c){c.nextAction="Register",c.reguserid="",c.invalid=!1;var d=/(\$|#|\+|\/|\\)+/i;c.$watch("reguserid",function(){c.invalid=c.reguserid.length<1||d.test(c.reguserid)?!0:!1}),c.onRegClick=function(){"Register"!==c.nextAction||d.test(c.reguserid)?(b.debug("Unregister: reguserid ="+c.reguserid),a.unregister()):(b.debug("Register: reguserid ="+c.reguserid),a.register(c.reguserid))},c.$on("rtcomm::init",function(a,b,d){1==b?(c.nextAction="Unregister",c.reguserid=d.userid):(c.nextAction="Register",c.reguserid="destroyed"==d?"":"Init failed:"+d)})}],controllerAs:"register"}}function c(a,b){return{restrict:"E",templateUrl:"templates/rtcomm/rtcomm-queues.html",controller:["$scope",function(c){c.rQueues=[],c.autoJoinQueues=!1,c.queuePresenceData=[],c.queuePublishPresence=!1,c.queueFilter=null,c.init=function(a,d,e){b.debug("rtcommQueues: autoJoinQueues = "+a),c.autoJoinQueues=a,c.queuePublishPresence=d,"undefined"!=typeof e&&(c.queueFilter=e)},c.$on("queueupdate",function(a,d){b.debug("rtcommQueues: scope queues",c.rQueues),Object.keys(d).forEach(function(a){b.debug("rtcommQueues: Push queue: "+d[a]),b.debug("rtcommQueues: autoJoinQueues: "+c.autoJoinQueues),0==c.filterOutQueue(d[a])&&(c.rQueues.push(d[a]),1==c.autoJoinQueues&&c.onQueueClick(d[a]))}),c.updateQueuePresence()}),c.$on("rtcomm::init",function(a,d){0==d&&(b.debug("rtcommQueues: init: clear queues"),c.rQueues=[])}),c.filterOutQueue=function(a){var b=!0;if(null!=c.queueFilter)for(var d=0;d0?(d.bind("scroll",function(){a.scrollToBottom(d.prop("scrollTop")+d.prop("clientHeight")==d.prop("scrollHeight")?!0:!1)}),a.$watch("chats",function(){e&&d.scrollTop(d.prop("scrollHeight"))},!0)):b.warn("chatPanel not found: most likely you need to load jquery prior to angular")}}}function h(a,b,c,d,e){return{restrict:"E",templateUrl:"templates/rtcomm/rtcomm-iframe.html",controller:["$scope",function(f){f.iframeActiveEndpointUUID=a.getActiveEndpoint(),f.iframeURL=null,f.initiframeURL=null,f.syncSource=!1,f.init=function(a){1==a&&(f.syncSource=!0,f.initiframeURL=d.absUrl())},f.$on("session:started",function(c,d){b.debug("session:started received: endpointID = "+d.endpoint.id),1==f.syncSource&&a.putIframeURL(d.endpoint.id,f.initiframeURL)}),f.$on("endpointActivated",function(d,e){b.debug("rtcommIframe: endpointActivated ="+e),0==f.syncSource&&(f.iframeURL=c.trustAsResourceUrl(a.getIframeURL(e)),f.iframeActiveEndpointUUID=e)}),f.$on("noEndpointActivated",function(){0==f.syncSource&&(f.iframeURL=c.trustAsResourceUrl("about:blank"),f.iframeActiveEndpointUUID=null)}),f.$on("rtcomm::iframeUpdate",function(a,d,g){0==f.syncSource?(b.debug("rtcomm::iframeUpdate: "+g),g+="?disableRtcomm=true",f.iframeURL=c.trustAsResourceUrl(g)):(b.debug("rtcomm::iframeUpdate: load this url in a new tab: "+g),e.open(c.trustAsResourceUrl(g),"_blank"))}),f.setURL=function(d){b.debug("rtcommIframe: setURL: newURL: "+d),a.putIframeURL(f.iframeActiveEndpointUUID,d),f.iframeURL=c.trustAsResourceUrl(d)},f.forward=function(){},f.backward=function(){}}],controllerAs:"rtcommiframe"}}function i(a,b,c,d,e){b.alertingEndpointUUID=null,b.autoAnswerNewMedia=!1,b.alertActiveEndpointUUID=c.getActiveEndpoint(),b.caller=null,b.init=function(a){e.debug("rtcommAlert: autoAnswerNewMedia = "+a),b.autoAnswerNewMedia=a},b.$on("endpointActivated",function(a,c){b.alertActiveEndpointUUID=c}),b.$on("session:alerting",function(a,c){b.alertActiveEndpointUUID==c.endpoint.id&&0==b.autoAnswerNewMedia||b.alertActiveEndpointUUID!=c.endpoint.id?(e.debug("rtcommAlert: display alterting model: alertActiveEndpointUUID = "+c.endpoint+" autoAnswerNewMedia = "+b.autoAnswerNewMedia),b.caller=c.endpoint.getRemoteEndpointID(),b.alertingEndpointUUID=c.endpoint.id,b.showAlerting()):(e.debug("Accepting media from: "+c.endpoint.getRemoteEndpointID()+" for endpoint: "+c.endpoint.id),c.endpoint.accept())}),b.showAlerting=function(f){var g=d.open({templateUrl:"templates/rtcomm/rtcomm-modal-alert.html",controller:"RtcommAlertModalInstanceController",size:f,backdrop:"static",resolve:{caller:function(){return b.caller}}});g.result.then(function(){var d=c.getEndpoint(b.alertingEndpointUUID);d&&(e.debug("Accepting call from: "+b.caller+" for endpoint: "+b.alertingEndpointUUID),d.accept(),a.$broadcast("rtcomm::alert-success"),d=null)},function(){var a=c.getEndpoint(b.alertingEndpointUUID);a&&(e.debug("Rejecting call from: "+b.caller+" for endpoint: "+b.alertingEndpointUUID),a.reject(),a=null)})}}function j(a,b,c,d){a.caller=d,a.ok=function(){c.debug("Accepting alerting call"),b.close()},a.cancel=function(){c.debug("Rejecting alerting call"),b.dismiss("cancel")}}function k(a,b,c,d){a.calleeID=null,a.callerID=null,a.enableCallModel=!1,a.mediaToEnable=["chat"],a.init=function(b,c){a.calleeID=b,"undefined"!=typeof c&&(a.mediaToEnable=c)},a.$on("rtcomm::init",function(b,c){d.debug("RtcommCallModalController: rtcomm::init: success = "+c),a.enableCallModel=1==c?!0:!1}),a.$on("session:started",function(){a.enableCallModel=!1}),a.$on("session:stopped",function(){a.enableCallModel=!0}),a.placeCall=function(e){var f=c.open({templateUrl:"templates/rtcomm/rtcomm-modal-call.html",controller:"RtcommCallModalInstanceController",size:e,resolve:{}});f.result.then(function(c){d.debug("rtcommCallModal: Calling calleeID: "+a.calleeID),d.debug("rtcommCallModal: CallerID: "+c),null==a.callerID&&"undefined"!=typeof c&&""!=c&&(a.callerID=c,b.setAlias(c)),b.placeCall(a.calleeID,a.mediaToEnable)},function(){d.info("Modal dismissed at: "+new Date)})}}function l(a,b){a.endpointAlias="",a.ok=function(){b.close(a.endpointAlias)},a.cancel=function(){b.dismiss("cancel")}}function m(a,b,c,d){a.extendedConfig=null,d.debug("RtcommConfigController: configURL = "+a.configURL),a.setConfig=function(a){d.debug("RtcommConfigController: setting config data:"+a),c.setConfig(a)},a.init=function(b,c){d.debug("RtcommConfigController: initing configURL = "+b),a.configURL=b,"undefined"!=typeof c&&(a.extendedConfig=c),a.getConfig()},a.getConfig=function(){b.get(a.configURL).success(function(b){null!=a.extendedConfig&&(angular.extend(b,a.extendedConfig),d.debug("RtcommConfigController: extended config object: "+b)),c.setConfig(b)}).error(function(a,b){d.debug("RtcommConfigController: error accessing config: "+b)})}}function n(a,b,c,d){a.avConnected=c.isWebrtcConnected(c.getActiveEndpoint()),a.init=function(a,b){c.setViewSelector(a,b);var d=c.getActiveEndpoint();"undefined"!=typeof d&&null!=d&&c.setVideoView(d)};var e=c.getActiveEndpoint();"undefined"!=typeof e&&null!=e&&c.setVideoView(e),a.$on("endpointActivated",function(b,e){d.debug("rtcommVideo: endpointActivated ="+e),c.setVideoView(e),a.avConnected=c.isWebrtcConnected(c.getActiveEndpoint())}),a.$on("noEndpointActivated",function(){a.avConnected=!1}),a.$on("webrtc:connected",function(b,d){c.getActiveEndpoint()==d.endpoint.id&&(a.avConnected=!0)}),a.$on("webrtc:disconnected",function(b,d){c.getActiveEndpoint()==d.endpoint.id&&(a.avConnected=!1)})}function o(a,b,c,d,e){a.epCtrlActiveEndpointUUID=d.getActiveEndpoint(),a.epCtrlAVConnected=d.isWebrtcConnected(a.epCtrlActiveEndpointUUID),a.sessionState=d.getSessionState(a.epCtrlActiveEndpointUUID),a.disconnect=function(){e.debug("Disconnecting call for endpoint: "+a.epCtrlActiveEndpointUUID),d.getEndpoint(a.epCtrlActiveEndpointUUID).disconnect()},a.toggleAV=function(){e.debug("Enable AV for endpoint: "+a.epCtrlActiveEndpointUUID),0==a.epCtrlAVConnected?d.getEndpoint(a.epCtrlActiveEndpointUUID).webrtc.enable(function(a,b){a||(e.debug("Enable failed: ",b),d.alert({type:"danger",msg:b}))}):(e.debug("Disable AV for endpoint: "+a.epCtrlActiveEndpointUUID),d.getEndpoint(a.epCtrlActiveEndpointUUID).webrtc.disable())},a.$on("session:started",function(b,c){e.debug("session:started received: endpointID = "+c.endpoint.id),a.epCtrlActiveEndpointUUID==c.endpoint.id&&(a.sessionState="session:started")}),a.$on("session:stopped",function(b,c){e.debug("session:stopped received: endpointID = "+c.endpoint.id),a.epCtrlActiveEndpointUUID==c.endpoint.id&&(a.sessionState="session:stopped")}),a.$on("session:failed",function(b,c){e.debug("session:failed received: endpointID = "+c.endpoint.id),a.epCtrlActiveEndpointUUID==c.endpoint.id&&(a.sessionState="session:failed")}),a.$on("webrtc:connected",function(b,c){a.epCtrlActiveEndpointUUID==c.endpoint.id&&(a.epCtrlAVConnected=!0)}),a.$on("webrtc:disconnected",function(b,c){a.epCtrlActiveEndpointUUID==c.endpoint.id&&(a.epCtrlAVConnected=!1)}),a.$on("endpointActivated",function(b,c){a.epCtrlActiveEndpointUUID=c,a.epCtrlAVConnected=d.isWebrtcConnected(c)}),a.$on("noEndpointActivated",function(){a.epCtrlAVConnected=!1})}angular.module("angular-rtcomm-ui",["ui.bootstrap","angular-rtcomm-service"]).directive("rtcommSessionManager",a).directive("rtcommRegister",b).directive("rtcommQueues",c).directive("rtcommAlert",d).directive("rtcommEndpointStatus",e).directive("rtcommVideo",f).directive("rtcommChat",g).directive("rtcommIframe",h).controller("RtcommAlertModalController",i).controller("RtcommAlertModalInstanceController",j).controller("RtcommCallModalController",k).controller("RtcommCallModalInstanceController",l).controller("RtcommConfigController",m).controller("RtcommVideoController",n).controller("RtcommEndpointController",o),a.$inject=["RtcommService","$log"],b.$inject=["RtcommService","$log"],c.$inject=["RtcommService","$log"],d.$inject=["$log"],e.$inject=["RtcommService","$log"],f.$inject=["RtcommService","$log"],g.$inject=["RtcommService","$log"],h.$inject=["RtcommService","$log","$sce","$location","$window"],i.$inject=["$rootScope","$scope","RtcommService","$modal","$log"],j.$inject=["$scope","$modalInstance","$log","caller"],k.$inject=["$scope","RtcommService","$modal","$log"],l.$inject=["$scope","$modalInstance","RtcommService"],m.$inject=["$scope","$http","RtcommService","$log"],n.$inject=["$scope","$http","RtcommService","$log"],o.$inject=["$scope","$rootScope","$http","RtcommService","$log"]}(),function(){function a(a,b){return{restrict:"E",templateUrl:"templates/rtcomm/rtcomm-presence.html",controller:["$scope","$rootScope",function(c,d){c.monitorTopics=[],c.presenceData=[],c.expandedNodes=[],c.protocolList={chat:!0,webrtc:!1},c.flatten=!1,c.treeOptions={nodeChildren:"nodes",dirSelectable:!0,injectClasses:{ul:"a1",li:"a2",liSelected:"a7",iExpanded:"a3",iCollapsed:"a4",iLeaf:"a5",label:"a6",labelSelected:"a8"}},c.init=function(a){c.protocolList.chat="boolean"==typeof a.chat?a.chat:c.protocolList.chat,c.protocolList.webrtc="boolean"==typeof a.webrtc?a.webrtc:c.protocolList.webrtc,c.flatten="boolean"==typeof a.flatten?a.flatten:c.flatten},c.onCallClick=function(b){var e=a.getEndpoint();a.setActiveEndpoint(e.id),1==c.protocolList.chat&&e.chat.enable(),1==c.protocolList.webrtc&&e.webrtc.enable(function(b,c){b||a.alert({type:"danger",msg:c})}),e.connect(b),d.$broadcast("rtcomm::presence-click")},c.$on("rtcomm::init",function(){a.publishPresence();var d=a.getPresenceMonitor();d.on("updated",function(a){b.debug("<<------rtcommPresence: updated------>>"),c.flatten&&(b.debug("<<------rtcommPresence: updated using flattened data ------>>"),c.presenceData=a[0].flatten()),c.$apply()}),c.flatten||(c.presenceData=d.getPresenceData()),c.presenceData.length>=1&&c.expandedNodes.push(c.presenceData[0]);for(var e=0;e{{alert.msg}}'),a.put("templates/rtcomm/rtcomm-chat.html",'
Chat
  • {{chat.name}} {{chat.time | date:\'HH:mm:ss\'}}

    {{chat.message}}

'),a.put("templates/rtcomm/rtcomm-endpoint-status.html",'
'),a.put("templates/rtcomm/rtcomm-iframe.html",'
URL Sharing
'),a.put("templates/rtcomm/rtcomm-modal-alert.html",''),a.put("templates/rtcomm/rtcomm-modal-call.html",''),a.put("templates/rtcomm/rtcomm-queues.html",'
Queues
'),a.put("templates/rtcomm/rtcomm-register.html",'
'),a.put("templates/rtcomm/rtcomm-sessionmgr.html",'
'),a.put("templates/rtcomm/rtcomm-video.html",'
') -}]),angular.module("angular-rtcomm-presence").run(["$templateCache",function(a){"use strict";a.put("templates/rtcomm/rtcomm-presence.html",'
{{node.name}} {{node.value ? \': \' + node.value : \'\'}}
')}]); \ No newline at end of file +!function(){angular.module("angular-rtcomm",["ui.bootstrap","treeControl","angular-rtcomm-ui","angular-rtcomm-presence","angular-rtcomm-service"])}(),function(){function a(a,b,c){b.debug("RtcommConfigService: Abs URL: "+a.absUrl());var d=a.search().disableRtcomm;d="undefined"==typeof d||null===d?!1:"true"===d?!0:!1,b.debug("RtcommConfigService: _disableRtcomm = "+d);var e={server:a.host(),port:a.port(),rtcommTopicPath:"/rtcomm/",createEndpoint:!1,appContext:"default",userid:"",presence:{topic:""}};b.debug("providerConfig.server: "+e.server),b.debug("providerConfig.port: "+e.port);var f={chat:!0,webrtc:!0},g=!0,h=!0,i="DEBUG",j=null,k=null,l=!0,m=function(a){e.server="undefined"!=typeof a.server?a.server:e.server,e.port="undefined"!=typeof a.port?a.port:e.port,e.rtcommTopicPath="undefined"!=typeof a.rtcommTopicPath?a.rtcommTopicPath:e.rtcommTopicPath,e.createEndpoint="undefined"!=typeof a.createEndpoint?a.createEndpoint:e.createEndpoint,e.appContext="undefined"!=typeof a.appContext?a.appContext:e.appContext,e.presence.topic="undefined"!=typeof a.presenceTopic?a.presenceTopic:e.presence.topic,f.chat="undefined"!=typeof a.chat?a.chat:f.chat,f.webrtc="undefined"!=typeof a.webrtc?a.webrtc:f.webrtc,g="undefined"!=typeof a.broadcastAudio?a.broadcastAudio:g,h="undefined"!=typeof a.broadcastVideo?a.broadcastVideo:h,l="undefined"!=typeof a.trickleICE?a.trickleICE:l,k="undefined"!=typeof a.ringbacktone?a.ringbacktone:k,j="undefined"!=typeof a.ringtone?a.ringtone:j,i="undefined"!=typeof a.rtcommDebug?a.rtcommDebug:i,b.debug("rtcommDebug from config is: "+a.rtcommDebug),"undefined"!=typeof a.userid&&(e.userid=a.userid),b.debug("providerConfig is now: ",e)};return{setProviderConfig:function(a){m(a)},getProviderConfig:function(){return e},getWebRTCEnabled:function(){return f.webrtc},getChatEnabled:function(){return f.chat},getBroadcastAudio:function(){return g},getBroadcastVideo:function(){return h},getRingTone:function(){return j},getRingBackTone:function(){return k},getRtcommDebug:function(){return i},isRtcommDisabled:function(){return d},getTrickleICE:function(){return l}}}function b(a,b,c,d){var e=new rtcomm.EndpointProvider,f=!1,g=null,h=[],i=null,j=!1,k="selfView",l="remoteView";e.setLogLevel(d.getRtcommDebug()),b.debug("rtcomm-service - endpointProvider log level is: "+e.getLogLevel()),b.debug("rtcomm-service - endpointProvider log level should be: "+d.getRtcommDebug()),e.setAppContext(d.getProviderConfig().appContext);var m=function(){return null==i&&(i={state:"available",userDefines:[]}),i},n=function(){var a={ringbacktone:d.getRingBackTone(),ringtone:d.getRingTone(),webrtcConfig:{broadcast:{audio:d.getBroadcastAudio(),video:d.getBroadcastVideo()},trickleICE:d.getTrickleICE()},webrtc:d.getWebRTCEnabled(),chat:d.getChatEnabled()};return a};e.on("reset",function(a){f=!1,x({type:"danger",msg:a.reason})}),e.on("queueupdate",function(c){b.debug("<<------rtcomm-service------>> - Event: queueupdate"),b.debug("queueupdate",c),a.$evalAsync(function(){a.$broadcast("queueupdate",c)})}),e.on("newendpoint",function(c){b.debug("<<------rtcomm-service------>> - Event: newendpoint remoteEndpointID: "+c.getRemoteEndpointID()),c.on("onetimemessage",function(c){if(b.debug("<<------rtcomm-onetimemessage------>> - Event: ",c),"undefined"!=c.onetimemessage.type&&"iFrameURL"==c.onetimemessage.type){var d=s(c.endpoint.id);d.iFrameURL=c.onetimemessage.iFrameURL,a.$evalAsync(function(){a.$broadcast("rtcomm::iframeUpdate",c.endpoint.id,c.onetimemessage.iFrameURL)})}}),a.$evalAsync(function(){a.$broadcast("newendpoint",c)})});var o=function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){if(c.eventName.indexOf("session:")>-1){var b=s(c.endpoint.id);b.sessionState=c.eventName}a.$broadcast(c.eventName,c)}),1==j&&a.$digest()};e.setRtcommEndpointConfig({ringtone:d.getRingTone(),ringbacktone:d.getRingBackTone(),"session:started":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){var b=s(c.endpoint.id);v(c.endpoint.id),b.sessionStarted=!0,b.remoteEndpointID=c.endpoint.getRemoteEndpointID(),a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},"session:alerting":o,"session:trying":o,"session:ringing":o,"session:queued":o,"session:failed":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){t(c.endpoint.id),a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},"session:stopped":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){t(c.endpoint.id),a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},"session:connecting":o,"webrtc:connected":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){s(c.endpoint.id).webrtcConnected=!0,a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},"webrtc:remotemuted":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},"webrtc:disconnected":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){var b=r(c.endpoint.id);null!=b&&(b.webrtcConnected=!1),a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},"chat:connected":o,"chat:disconnected":o,"chat:message":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){var b={time:new Date,name:c.message.from,message:angular.copy(c.message.message)};s(c.endpoint.id).chats.push(b),a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},destroyed:o});var p=function(c){b.debug("<<------rtcomm-service------>> - Event: Provider init succeeded"),null!=i&&(b.debug("RtcommService: initSuccess: updating presence record"),e.publishPresence(i)),a.$evalAsync(function(){var b={ready:c.ready,registered:c.registered,endpoint:c.endpoint,userid:d.getProviderConfig().userid};a.$broadcast("rtcomm::init",!0,b)}),1==j&&a.$digest()},q=function(c){b.debug("<<------rtcomm-service------>> - Event: Provider init failed: error: ",c),a.$evalAsync(function(){a.$broadcast("rtcomm::init",!1,c)}),1==j&&a.$digest()},r=function(a){for(var b=null,c=0;c> - Event: ",c),"undefined"!=c.onetimemessage.type&&"iFrameURL"==c.onetimemessage.type){var d=s(c.endpoint.id);d.iFrameURL=c.onetimemessage.iFrameURL,a.$evalAsync(function(){a.$broadcast("rtcomm::iframeUpdate",c.endpoint.id,c.onetimemessage.iFrameURL)})}})):d=e.getRtcommEndpoint(c),d},v=function(b){var c=w();if(null!=c&&c!=b){var d=r(c);null!=d&&(d.activated=!1)}var d=s(b);d.activated=!0,a.$broadcast("endpointActivated",b)},w=function(){for(var a=null,b=0;b-1&&c.chat.enable(),b.indexOf("webrtc")>-1){var d=!0;b.indexOf("disableTrickleICE")>-1&&(d=!1),c.webrtc.enable({trickleICE:d})}return v(c.id),c.connect(a),c.id},getSessions:function(){return h},endCall:function(a){a.disconnect()},setActiveEndpoint:function(a){v(a)},getActiveEndpoint:function(){return w()},getRemoteEndpoint:function(a){var b=null;if(null!=a){var c=r(a);null!=c&&(b=c.remoteEndpointID)}return b},setDefaultViewSelector:function(){k="selfView",l="remoteView"},setViewSelector:function(a,b){k=a,l=b},setVideoView:function(a){b.debug("rtcommVideo: setting local media");var c=null;"undefined"!=typeof a&&null!=a?c=u(a):null!=w()&&(c=u(w())),null!=c&&c.webrtc.setLocalMedia({mediaOut:document.querySelector("#"+k),mediaIn:document.querySelector("#"+l)})}}}angular.module("angular-rtcomm-service",[]).config(["$logProvider",function(a){a.debugEnabled(!0)}]).factory("RtcommConfigService",a).factory("RtcommService",b),a.$inject=["$location","$log","$window"],b.$inject=["$rootScope","$log","$http","RtcommConfigService"]}(),function(){function a(a,b){return{restrict:"E",templateUrl:"templates/rtcomm/rtcomm-sessionmgr.html",controller:["$scope",function(c){c.sessions=a.getSessions(),c.sessMgrActiveEndpointUUID=a.getActiveEndpoint(),c.publishPresence=!1,c.sessionPresenceData=[],c.init=function(a){c.publishPresence=a,c.updatePresence()},c.$on("endpointActivated",function(a,d){b.debug("rtcommSessionmgr: endpointActivated ="+d),c.sessMgrActiveEndpointUUID=d}),c.$on("session:started",function(a,d){b.debug("rtcommSessionmgr: session:started: uuid ="+d.endpoint.id),c.updatePresence()}),c.activateSession=function(d){b.debug("rtcommSessionmgr: activateEndpoint ="+d),c.sessMgrActiveEndpointUUID!=d&&a.setActiveEndpoint(d)},c.updatePresence=function(){1==c.publishPresence&&(a.removeFromPresenceRecord(c.sessionPresenceData,!1),c.sessionPresenceData=[{name:"sessions",value:String(c.sessions.length)}],a.addToPresenceRecord(c.sessionPresenceData))}}],controllerAs:"sessionmgr"}}function b(a,b){return{restrict:"E",templateUrl:"templates/rtcomm/rtcomm-register.html",controller:["$scope",function(c){c.nextAction="Register",c.reguserid="",c.invalid=!1;var d=/(\$|#|\+|\/|\\)+/i;c.$watch("reguserid",function(){c.reguserid.length<1||d.test(c.reguserid)?c.invalid=!0:c.invalid=!1}),c.onRegClick=function(){"Register"!==c.nextAction||d.test(c.reguserid)?(b.debug("Unregister: reguserid ="+c.reguserid),a.unregister()):(b.debug("Register: reguserid ="+c.reguserid),a.register(c.reguserid))},c.$on("rtcomm::init",function(a,b,d){1==b?(c.nextAction="Unregister",c.reguserid=d.userid):(c.nextAction="Register","destroyed"==d?c.reguserid="":c.reguserid="Init failed:"+d)})}],controllerAs:"register"}}function c(a,b){return{restrict:"E",templateUrl:"templates/rtcomm/rtcomm-queues.html",controller:["$scope",function(c){c.rQueues=[],c.autoJoinQueues=!1,c.queuePresenceData=[],c.queuePublishPresence=!1,c.queueFilter=null,c.init=function(a,d,e){b.debug("rtcommQueues: autoJoinQueues = "+a),c.autoJoinQueues=a,c.queuePublishPresence=d,"undefined"!=typeof e&&(c.queueFilter=e)},c.$on("queueupdate",function(a,d){b.debug("rtcommQueues: scope queues",c.rQueues),Object.keys(d).forEach(function(a){b.debug("rtcommQueues: Push queue: "+d[a]),b.debug("rtcommQueues: autoJoinQueues: "+c.autoJoinQueues),0==c.filterOutQueue(d[a])&&(c.rQueues.push(d[a]),1==c.autoJoinQueues&&c.onQueueClick(d[a]))}),c.updateQueuePresence()}),c.$on("rtcomm::init",function(a,d,e){0==d&&(b.debug("rtcommQueues: init: clear queues"),c.rQueues=[])}),c.filterOutQueue=function(a){var b=!0;if(null!=c.queueFilter)for(var d=0;d0?(d.bind("scroll",function(){d.prop("scrollTop")+d.prop("clientHeight")==d.prop("scrollHeight")?a.scrollToBottom(!0):a.scrollToBottom(!1)}),a.$watch("chats",function(){e&&d.scrollTop(d.prop("scrollHeight"))},!0)):b.warn("chatPanel not found: most likely you need to load jquery prior to angular")}}}function h(a,b,c,d,e){return{restrict:"E",templateUrl:"templates/rtcomm/rtcomm-iframe.html",controller:["$scope",function(f){f.iframeActiveEndpointUUID=a.getActiveEndpoint(),f.iframeURL=null,f.initiframeURL=null,f.syncSource=!1,f.init=function(a){1==a&&(f.syncSource=!0,f.initiframeURL=d.absUrl())},f.$on("session:started",function(c,d){b.debug("session:started received: endpointID = "+d.endpoint.id),1==f.syncSource&&a.putIframeURL(d.endpoint.id,f.initiframeURL)}),f.$on("endpointActivated",function(d,e){b.debug("rtcommIframe: endpointActivated ="+e),0==f.syncSource&&(f.iframeURL=c.trustAsResourceUrl(a.getIframeURL(e)),f.iframeActiveEndpointUUID=e)}),f.$on("noEndpointActivated",function(a){0==f.syncSource&&(f.iframeURL=c.trustAsResourceUrl("about:blank"),f.iframeActiveEndpointUUID=null)}),f.$on("rtcomm::iframeUpdate",function(a,d,g){0==f.syncSource?(b.debug("rtcomm::iframeUpdate: "+g),g+="?disableRtcomm=true",f.iframeURL=c.trustAsResourceUrl(g)):(b.debug("rtcomm::iframeUpdate: load this url in a new tab: "+g),e.open(c.trustAsResourceUrl(g),"_blank"))}),f.setURL=function(d){b.debug("rtcommIframe: setURL: newURL: "+d),a.putIframeURL(f.iframeActiveEndpointUUID,d),f.iframeURL=c.trustAsResourceUrl(d)},f.forward=function(){},f.backward=function(){}}],controllerAs:"rtcommiframe"}}function i(a,b,c,d,e){b.alertingEndpointUUID=null,b.autoAnswerNewMedia=!1,b.alertActiveEndpointUUID=c.getActiveEndpoint(),b.caller=null,b.init=function(a){e.debug("rtcommAlert: autoAnswerNewMedia = "+a),b.autoAnswerNewMedia=a},b.$on("endpointActivated",function(a,c){b.alertActiveEndpointUUID=c}),b.$on("session:alerting",function(a,c){b.alertActiveEndpointUUID==c.endpoint.id&&0==b.autoAnswerNewMedia||b.alertActiveEndpointUUID!=c.endpoint.id?(e.debug("rtcommAlert: display alterting model: alertActiveEndpointUUID = "+c.endpoint+" autoAnswerNewMedia = "+b.autoAnswerNewMedia),b.caller=c.endpoint.getRemoteEndpointID(),b.alertingEndpointUUID=c.endpoint.id,b.showAlerting()):(e.debug("Accepting media from: "+c.endpoint.getRemoteEndpointID()+" for endpoint: "+c.endpoint.id),c.endpoint.accept())}),b.showAlerting=function(f){var g=d.open({templateUrl:"templates/rtcomm/rtcomm-modal-alert.html",controller:"RtcommAlertModalInstanceController",size:f,backdrop:"static",resolve:{caller:function(){return b.caller}}});g.result.then(function(){var d=c.getEndpoint(b.alertingEndpointUUID);d&&(e.debug("Accepting call from: "+b.caller+" for endpoint: "+b.alertingEndpointUUID),d.accept(),a.$broadcast("rtcomm::alert-success"),d=null)},function(){var a=c.getEndpoint(b.alertingEndpointUUID);a&&(e.debug("Rejecting call from: "+b.caller+" for endpoint: "+b.alertingEndpointUUID),a.reject(),a=null)})}}function j(a,b,c,d){a.caller=d,a.ok=function(){c.debug("Accepting alerting call"),b.close()},a.cancel=function(){c.debug("Rejecting alerting call"),b.dismiss("cancel")}}function k(a,b,c,d){a.calleeID=null,a.callerID=null,a.enableCallModel=!1,a.mediaToEnable=["chat"],a.init=function(b,c){a.calleeID=b,"undefined"!=typeof c&&(a.mediaToEnable=c)},a.$on("rtcomm::init",function(b,c,e){d.debug("RtcommCallModalController: rtcomm::init: success = "+c),1==c?a.enableCallModel=!0:a.enableCallModel=!1}),a.$on("session:started",function(b,c){a.enableCallModel=!1}),a.$on("session:stopped",function(b,c){a.enableCallModel=!0}),a.placeCall=function(e){var f=c.open({templateUrl:"templates/rtcomm/rtcomm-modal-call.html",controller:"RtcommCallModalInstanceController",size:e,resolve:{}});f.result.then(function(c){d.debug("rtcommCallModal: Calling calleeID: "+a.calleeID),d.debug("rtcommCallModal: CallerID: "+c),null==a.callerID&&"undefined"!=typeof c&&""!=c&&(a.callerID=c,b.setAlias(c)),b.placeCall(a.calleeID,a.mediaToEnable)},function(){d.info("Modal dismissed at: "+new Date)})}}function l(a,b,c){a.endpointAlias="",a.ok=function(){b.close(a.endpointAlias)},a.cancel=function(){b.dismiss("cancel")}}function m(a,b,c,d){a.extendedConfig=null,d.debug("RtcommConfigController: configURL = "+a.configURL),a.setConfig=function(a){d.debug("RtcommConfigController: setting config data:"+a),c.setConfig(a)},a.init=function(b,c){d.debug("RtcommConfigController: initing configURL = "+b),a.configURL=b,"undefined"!=typeof c&&(a.extendedConfig=c),a.getConfig()},a.getConfig=function(){b.get(a.configURL).success(function(b){null!=a.extendedConfig&&(angular.extend(b,a.extendedConfig),d.debug("RtcommConfigController: extended config object: "+b)),c.setConfig(b)}).error(function(a,b,c,e){d.debug("RtcommConfigController: error accessing config: "+b)})}}function n(a,b,c,d){a.avConnected=c.isWebrtcConnected(c.getActiveEndpoint()),a.init=function(a,b){c.setViewSelector(a,b);var d=c.getActiveEndpoint();"undefined"!=typeof d&&null!=d&&c.setVideoView(d)};var e=c.getActiveEndpoint();"undefined"!=typeof e&&null!=e&&c.setVideoView(e),a.$on("endpointActivated",function(b,e){d.debug("rtcommVideo: endpointActivated ="+e),c.setVideoView(e),a.avConnected=c.isWebrtcConnected(c.getActiveEndpoint())}),a.$on("noEndpointActivated",function(b){a.avConnected=!1}),a.$on("webrtc:connected",function(b,d){c.getActiveEndpoint()==d.endpoint.id&&(a.avConnected=!0)}),a.$on("webrtc:disconnected",function(b,d){c.getActiveEndpoint()==d.endpoint.id&&(a.avConnected=!1)})}function o(a,b,c,d,e){a.epCtrlActiveEndpointUUID=d.getActiveEndpoint(),a.epCtrlAVConnected=d.isWebrtcConnected(a.epCtrlActiveEndpointUUID),a.sessionState=d.getSessionState(a.epCtrlActiveEndpointUUID),a.disconnect=function(){e.debug("Disconnecting call for endpoint: "+a.epCtrlActiveEndpointUUID),d.getEndpoint(a.epCtrlActiveEndpointUUID).disconnect()},a.toggleAV=function(){e.debug("Enable AV for endpoint: "+a.epCtrlActiveEndpointUUID),0==a.epCtrlAVConnected?d.getEndpoint(a.epCtrlActiveEndpointUUID).webrtc.enable(function(a,b){a||(e.debug("Enable failed: ",b),d.alert({type:"danger",msg:b}))}):(e.debug("Disable AV for endpoint: "+a.epCtrlActiveEndpointUUID),d.getEndpoint(a.epCtrlActiveEndpointUUID).webrtc.disable())},a.$on("session:started",function(b,c){e.debug("session:started received: endpointID = "+c.endpoint.id),a.epCtrlActiveEndpointUUID==c.endpoint.id&&(a.sessionState="session:started")}),a.$on("session:stopped",function(b,c){e.debug("session:stopped received: endpointID = "+c.endpoint.id),a.epCtrlActiveEndpointUUID==c.endpoint.id&&(a.sessionState="session:stopped")}),a.$on("session:failed",function(b,c){e.debug("session:failed received: endpointID = "+c.endpoint.id),a.epCtrlActiveEndpointUUID==c.endpoint.id&&(a.sessionState="session:failed")}),a.$on("webrtc:connected",function(b,c){a.epCtrlActiveEndpointUUID==c.endpoint.id&&(a.epCtrlAVConnected=!0)}),a.$on("webrtc:disconnected",function(b,c){a.epCtrlActiveEndpointUUID==c.endpoint.id&&(a.epCtrlAVConnected=!1)}),a.$on("endpointActivated",function(b,c){a.epCtrlActiveEndpointUUID=c,a.epCtrlAVConnected=d.isWebrtcConnected(c)}),a.$on("noEndpointActivated",function(b){a.epCtrlAVConnected=!1})}angular.module("angular-rtcomm-ui",["ui.bootstrap","angular-rtcomm-service"]).directive("rtcommSessionManager",a).directive("rtcommRegister",b).directive("rtcommQueues",c).directive("rtcommAlert",d).directive("rtcommEndpointStatus",e).directive("rtcommVideo",f).directive("rtcommChat",g).directive("rtcommIframe",h).controller("RtcommAlertModalController",i).controller("RtcommAlertModalInstanceController",j).controller("RtcommCallModalController",k).controller("RtcommCallModalInstanceController",l).controller("RtcommConfigController",m).controller("RtcommVideoController",n).controller("RtcommEndpointController",o),a.$inject=["RtcommService","$log"],b.$inject=["RtcommService","$log"],c.$inject=["RtcommService","$log"],d.$inject=["$log"],e.$inject=["RtcommService","$log"],f.$inject=["RtcommService","$log"],g.$inject=["RtcommService","$log"],h.$inject=["RtcommService","$log","$sce","$location","$window"],i.$inject=["$rootScope","$scope","RtcommService","$modal","$log"],j.$inject=["$scope","$modalInstance","$log","caller"],k.$inject=["$scope","RtcommService","$modal","$log"],l.$inject=["$scope","$modalInstance","RtcommService"],m.$inject=["$scope","$http","RtcommService","$log"],n.$inject=["$scope","$http","RtcommService","$log"],o.$inject=["$scope","$rootScope","$http","RtcommService","$log"]}(),function(){function a(a,b){return{restrict:"E",templateUrl:"templates/rtcomm/rtcomm-presence.html",controller:["$scope","$rootScope",function(c,d){c.monitorTopics=[],c.presenceData=[],c.expandedNodes=[],c.protocolList={chat:!0,webrtc:!1},c.flatten=!1,c.treeOptions={nodeChildren:"nodes",dirSelectable:!0,injectClasses:{ul:"a1",li:"a2",liSelected:"a7",iExpanded:"a3",iCollapsed:"a4",iLeaf:"a5",label:"a6",labelSelected:"a8"}},c.init=function(a){c.protocolList.chat="boolean"==typeof a.chat?a.chat:c.protocolList.chat,c.protocolList.webrtc="boolean"==typeof a.webrtc?a.webrtc:c.protocolList.webrtc,c.flatten="boolean"==typeof a.flatten?a.flatten:c.flatten},c.onCallClick=function(b){var e=a.getEndpoint();a.setActiveEndpoint(e.id),1==c.protocolList.chat&&e.chat.enable(),1==c.protocolList.webrtc&&e.webrtc.enable(function(b,c){b||a.alert({type:"danger",msg:c})}),e.connect(b),d.$broadcast("rtcomm::presence-click")},c.$on("rtcomm::init",function(d,e,f){a.publishPresence();var g=a.getPresenceMonitor();g.on("updated",function(a){b.debug("<<------rtcommPresence: updated------>>"),c.flatten&&(b.debug("<<------rtcommPresence: updated using flattened data ------>>"),c.presenceData=a[0].flatten()),c.$apply()}),c.flatten||(c.presenceData=g.getPresenceData()),c.presenceData.length>=1&&c.expandedNodes.push(c.presenceData[0]);for(var h=0;h{{alert.msg}}'),a.put("templates/rtcomm/rtcomm-chat.html",'
Chat
  • {{chat.name}} {{chat.time | date:\'HH:mm:ss\'}}

    {{chat.message}}

'),a.put("templates/rtcomm/rtcomm-endpoint-status.html",'
'), +a.put("templates/rtcomm/rtcomm-iframe.html",'
URL Sharing
'),a.put("templates/rtcomm/rtcomm-modal-alert.html",''),a.put("templates/rtcomm/rtcomm-modal-call.html",''),a.put("templates/rtcomm/rtcomm-queues.html",'
Queues
'),a.put("templates/rtcomm/rtcomm-register.html",'
'),a.put("templates/rtcomm/rtcomm-sessionmgr.html",'
'),a.put("templates/rtcomm/rtcomm-video.html",'
')}]),angular.module("angular-rtcomm-presence").run(["$templateCache",function(a){"use strict";a.put("templates/rtcomm/rtcomm-presence.html",'
{{node.name}} {{node.value ? \': \' + node.value : \'\'}}
')}]); \ No newline at end of file diff --git a/src/js/rtcomm-directives.js b/src/js/rtcomm-directives.js index 04b9bb4..e2459de 100644 --- a/src/js/rtcomm-directives.js +++ b/src/js/rtcomm-directives.js @@ -6,7 +6,7 @@ angular .module('angular-rtcomm-ui', [ - 'ui.bootstrap', + 'ui.bootstrap', 'angular-rtcomm-service']) .directive('rtcommSessionManager', rtcommSessionManager) .directive('rtcommRegister', rtcommRegister) @@ -96,14 +96,14 @@ function rtcommRegister(RtcommService, $log) { controller: function ($scope) { $scope.nextAction = 'Register'; - + $scope.reguserid = ''; - + $scope.invalid = false; var invalidCharacters = /(\$|#|\+|\/|\\)+/i; //Invalid characters for MQTT Topic Path - - //Watch for changes in reguserid + + //Watch for changes in reguserid $scope.$watch('reguserid', function(){ if($scope.reguserid.length < 1 || invalidCharacters.test($scope.reguserid)){ @@ -361,6 +361,15 @@ function rtcommEndpointStatus(RtcommService, $log){ } }); + $scope.$on('session:connecting', function (event, eventObject) { + $log.debug('session:connecting received: endpointID = ' + eventObject.endpoint.id); + // if ($scope.epCtrlActiveEndpointUUID != eventObject.endpoint.id){ + $scope.sessionState = 'session:connecting'; + $scope.epCtrlRemoteEndpointID = eventObject.endpoint.getRemoteEndpointID(); + // } + }); + + $scope.$on('session:queued', function (event, eventObject) { $log.debug('session:queued received: endpointID = ' + eventObject.endpoint.id); if ($scope.epCtrlActiveEndpointUUID == eventObject.endpoint.id){ @@ -397,7 +406,12 @@ function rtcommEndpointStatus(RtcommService, $log){ }); $scope.$on('rtcomm::init', function(event, success, details){ - + if(success === true){ + $scope.epCtrlActiveEndpointUUID = RtcommService.getActiveEndpoint(); + $scope.epCtrlRemoteEndpointID = RtcommService.getRemoteEndpoint($scope.epCtrlActiveEndpointUUID); + $scope.sessionState = RtcommService.getSessionState($scope.epCtrlActiveEndpointUUID); + $scope.failureReason = ''; + } if(success == false){ $scope.sessionState = 'session:stopped'; $scope.epCtrlRemoteEndpointID = null; @@ -500,7 +514,7 @@ function rtcommChat(RtcommService, $log) { //In this else, a notification could be sent } },true); - } + } else { $log.warn('chatPanel not found: most likely you need to load jquery prior to angular'); } diff --git a/src/js/rtcomm-services.js b/src/js/rtcomm-services.js index 9adb257..ccffb61 100644 --- a/src/js/rtcomm-services.js +++ b/src/js/rtcomm-services.js @@ -61,6 +61,7 @@ var rtcommDebug = "DEBUG"; var ringtone = null; var ringbacktone = null; + var trickleICE = true; var setConfig = function(config){ providerConfig.server = (typeof config.server !== "undefined")? config.server : providerConfig.server; @@ -78,9 +79,10 @@ broadcastAudio = (typeof config.broadcastAudio !== "undefined")? config.broadcastAudio: broadcastAudio; broadcastVideo = (typeof config.broadcastVideo !== "undefined")? config.broadcastVideo: broadcastVideo; + trickleICE = (typeof config.trickleICE !== "undefined")? config.trickleICE: trickleICE; - ringbacktone = (typeof config.ringbacktone !== "undefined")? config.ringbacktone: null; - ringtone = (typeof config.ringtone !== "undefined")? config.ringtone : null; + ringbacktone = (typeof config.ringbacktone !== "undefined")? config.ringbacktone: ringbacktone; + ringtone = (typeof config.ringtone !== "undefined")? config.ringtone : ringtone; rtcommDebug = (typeof config.rtcommDebug !== "undefined")? config.rtcommDebug: rtcommDebug; @@ -112,7 +114,9 @@ getRtcommDebug: function(){return rtcommDebug;}, - isRtcommDisabled : function(){return _disableRtcomm;} + isRtcommDisabled : function(){return _disableRtcomm;}, + + getTrickleICE: function(){return trickleICE;} }; }; @@ -146,9 +150,12 @@ var mediaConfig = { ringbacktone: RtcommConfigService.getRingBackTone(), ringtone: RtcommConfigService.getRingTone(), - broadcast : { - audio : RtcommConfigService.getBroadcastAudio(), - video : RtcommConfigService.getBroadcastVideo() + webrtcConfig: { + broadcast : { + audio : RtcommConfigService.getBroadcastAudio(), + video : RtcommConfigService.getBroadcastVideo() + }, + trickleICE: RtcommConfigService.getTrickleICE() }, webrtc : RtcommConfigService.getWebRTCEnabled(), chat : RtcommConfigService.getChatEnabled(), @@ -158,7 +165,8 @@ }; myEndpointProvider.on('reset', function(event_object) { - // Should have a reason. + //The Endpoint provider is destroyed on reset + endpointProviderInitialized = false; _alert({type:'danger', msg: event_object.reason}); }); @@ -271,6 +279,8 @@ }, + 'session:connecting' : callback, + // These are all the WebRTC related events. 'webrtc:connected' : function(eventObject) { $log.debug('<<------rtcomm-service------>> - Event: ' + eventObject.eventName + ' remoteEndpointID: ' + eventObject.endpoint.getRemoteEndpointID()); @@ -434,7 +444,9 @@ for (var index = 0; index < sessions.length; index++) { if(sessions[index].endpointUUID === endpointUUID){ - _getEndpoint(endpointUUID).destroy(); + var endpoint = _getEndpoint(endpointUUID); + if(typeof endpoint !== 'undefined') + endpoint.destroy(); // Remove the disconnected endpoint from the list. sessions.splice(index, 1); diff --git a/src/templates/rtcomm/rtcomm-endpoint-status.html b/src/templates/rtcomm/rtcomm-endpoint-status.html index 8008020..d7ca13a 100644 --- a/src/templates/rtcomm/rtcomm-endpoint-status.html +++ b/src/templates/rtcomm/rtcomm-endpoint-status.html @@ -7,5 +7,7 @@ Call to {{epCtrlRemoteEndpointID}} is ringing Waiting in queue at: {{queueCount}} Call failed with reason: {{failureReason}} + Connecting to {{epCtrlRemoteEndpointID}} ... +