|
1 | | -/*! angular-vertxbus - v0.10.0 - 2014-12-14 |
| 1 | +/*! angular-vertxbus - v0.11.0 - 2014-12-18 |
2 | 2 | * http://github.com/knalli/angular-vertxbus |
3 | 3 | * Copyright (c) 2014 ; Licensed */ |
4 | 4 | (function() { |
|
139 | 139 | Furthermore, the stub supports theses extra APIs: |
140 | 140 | - recconnect() |
141 | 141 | */ |
142 | | - this.$get = ['$timeout', function($timeout) { |
| 142 | + this.$get = ['$timeout', '$log', function($timeout, $log) { |
143 | 143 | var EventBusOriginal, EventBusStub, connect, debugEnabled, enabled, eventBus, prefix, reconnectEnabled, sockjsOptions, sockjsReconnectInterval, sockjsStateInterval, url, urlPath, urlServer, _ref; |
144 | 144 | _ref = angular.extend({}, DEFAULT_OPTIONS, options), enabled = _ref.enabled, debugEnabled = _ref.debugEnabled, prefix = _ref.prefix, urlServer = _ref.urlServer, urlPath = _ref.urlPath, reconnectEnabled = _ref.reconnectEnabled, sockjsStateInterval = _ref.sockjsStateInterval, sockjsReconnectInterval = _ref.sockjsReconnectInterval, sockjsOptions = _ref.sockjsOptions; |
145 | 145 | EventBusStub = null; |
146 | 146 | EventBusOriginal = typeof vertx !== "undefined" && vertx !== null ? vertx.EventBus : void 0; |
147 | 147 | if (enabled && EventBusOriginal) { |
148 | 148 | url = "" + urlServer + urlPath; |
149 | 149 | if (debugEnabled) { |
150 | | - console.debug("[Vert.x EB Stub] Enabled: connecting '" + url + "'"); |
| 150 | + $log.debug("[Vert.x EB Stub] Enabled: connecting '" + url + "'"); |
151 | 151 | } |
152 | 152 | eventBus = null; |
153 | 153 | connect = function() { |
154 | 154 | eventBus = new EventBusOriginal(url, void 0, sockjsOptions); |
155 | 155 | eventBus.onopen = function() { |
156 | 156 | if (debugEnabled) { |
157 | | - console.debug("[Vert.x EB Stub] Connected"); |
| 157 | + $log.debug("[Vert.x EB Stub] Connected"); |
158 | 158 | } |
159 | 159 | if (typeof EventBusStub.onopen === 'function') { |
160 | 160 | EventBusStub.onopen(); |
161 | 161 | } |
162 | 162 | }; |
163 | 163 | eventBus.onclose = function() { |
164 | 164 | if (debugEnabled) { |
165 | | - console.debug("[Vert.x EB Stub] Reconnect in " + sockjsReconnectInterval + "ms"); |
| 165 | + $log.debug("[Vert.x EB Stub] Reconnect in " + sockjsReconnectInterval + "ms"); |
166 | 166 | } |
167 | 167 | if (typeof EventBusStub.onclose === 'function') { |
168 | 168 | EventBusStub.onclose(); |
|
224 | 224 | EventBusStub.getOptions.displayName = "" + CONSTANTS.MODULE + "/" + CONSTANTS.COMPONENT + ": EventBusStub.getOptions"; |
225 | 225 | } else { |
226 | 226 | if (debugEnabled) { |
227 | | - console.debug("[Vert.x EB Stub] Disabled"); |
| 227 | + $log.debug("[Vert.x EB Stub] Disabled"); |
228 | 228 | } |
229 | 229 | } |
230 | 230 | return EventBusStub; |
|
419 | 419 | return this; |
420 | 420 | }; |
421 | 421 | this.skipUnauthorizeds.displayName = "" + CONSTANTS.MODULE + "/" + CONSTANTS.COMPONENT + ": provider.skipUnauthorizeds"; |
422 | | - this.$get = ['$rootScope', '$q', '$interval', '$timeout', 'vertxEventBus', function($rootScope, $q, $interval, $timeout, vertxEventBus) { |
| 422 | + this.$get = ['$rootScope', '$q', '$interval', '$timeout', 'vertxEventBus', '$log', function($rootScope, $q, $interval, $timeout, vertxEventBus, $log) { |
423 | 423 | var connectionIntervalCheck, connectionState, debugEnabled, deconstructors, enabled, ensureOpenAuthConnection, ensureOpenConnection, loginPromise, messageBuffer, messageQueue, prefix, reconnectEnabled, sockjsOptions, sockjsReconnectInterval, sockjsStateInterval, urlPath, urlServer, util, validSession, wrapped, _ref, _ref1; |
424 | 424 | _ref = (vertxEventBus != null ? vertxEventBus.getOptions() : void 0) || {}, enabled = _ref.enabled, debugEnabled = _ref.debugEnabled, prefix = _ref.prefix, urlServer = _ref.urlServer, urlPath = _ref.urlPath, reconnectEnabled = _ref.reconnectEnabled, sockjsStateInterval = _ref.sockjsStateInterval, sockjsReconnectInterval = _ref.sockjsReconnectInterval, sockjsOptions = _ref.sockjsOptions, messageBuffer = _ref.messageBuffer; |
425 | 425 | connectionState = vertxEventBus != null ? (_ref1 = vertxEventBus.EventBus) != null ? _ref1.CLOSED : void 0 : void 0; |
|
480 | 480 | return true; |
481 | 481 | } else { |
482 | 482 | if (debugEnabled) { |
483 | | - console.debug("[Vert.x EB Service] Message was not sent because login is required"); |
| 483 | + $log.debug("[Vert.x EB Service] Message was not sent because login is required"); |
484 | 484 | } |
485 | 485 | return false; |
486 | 486 | } |
|
497 | 497 | return; |
498 | 498 | } |
499 | 499 | if (debugEnabled) { |
500 | | - console.debug("[Vert.x EB Service] Register handler for " + address); |
| 500 | + $log.debug("[Vert.x EB Service] Register handler for " + address); |
501 | 501 | } |
502 | 502 | if (deconstructors.containsKey(callback)) { |
503 | 503 | return deconstructors.get(callback); |
|
515 | 515 | return; |
516 | 516 | } |
517 | 517 | if (debugEnabled) { |
518 | | - console.debug("[Vert.x EB Service] Unregister handler for " + address); |
| 518 | + $log.debug("[Vert.x EB Service] Unregister handler for " + address); |
519 | 519 | } |
520 | 520 | vertxEventBus.unregisterHandler(address, deconstructors.get(callback)); |
521 | 521 | deconstructors.remove(callback); |
|
611 | 611 | wrapped.handlers[address].splice(index, 1); |
612 | 612 | } |
613 | 613 | } |
| 614 | + if (wrapped.handlers[address].length < 1) { |
| 615 | + wrapped.handlers[address] = void 0; |
| 616 | + } |
614 | 617 | }; |
615 | 618 | deconstructor.displayName = "" + CONSTANTS.MODULE + "/" + CONSTANTS.COMPONENT + ": wrapped.registerHandler (deconstructor)"; |
616 | 619 | return deconstructor; |
|
623 | 626 | wrapped.handlers[address].splice(index, 1); |
624 | 627 | } |
625 | 628 | } |
| 629 | + if (wrapped.handlers[address].length < 1) { |
| 630 | + wrapped.handlers[address] = void 0; |
| 631 | + } |
626 | 632 | if (connectionState === vertxEventBus.EventBus.OPEN) { |
627 | 633 | return util.unregisterHandler(address, callback); |
628 | 634 | } |
|
0 commit comments