Skip to content
This repository was archived by the owner on Jun 14, 2019. It is now read-only.

Commit 8cbca85

Browse files
committed
Release 1.1.0
1 parent 90bf569 commit 8cbca85

File tree

4 files changed

+97
-35
lines changed

4 files changed

+97
-35
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
<a name="1.1.0"></a>
2+
## 1.1.0 (2015-04-06)
3+
4+
5+
#### Features
6+
7+
* **service:** add 4th arg `service.send()` for replyless sends ([849eb3a1](http://github.com/knalli/angular-vertxbus/commit/849eb3a13b24eacba4d74e92504e77fa73d31515))
8+
* **wrapper:** add `wrapper.reconnect(true)` allowing a reconnect asap ([bd0cc4a3](http://github.com/knalli/angular-vertxbus/commit/bd0cc4a3dbd8e4cc47c041fe8a6aefd368cd0087))
9+
10+
111
<a name="1.0.0"></a>
212
## 1.0.0 (2015-03-01)
313

dist/angular-vertxbus.js

Lines changed: 43 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! angular-vertxbus - v1.0.0 - 2015-03-01
1+
/*! angular-vertxbus - v1.1.0 - 2015-04-06
22
* http://github.com/knalli/angular-vertxbus
33
* Copyright (c) 2015 ; Licensed */
44
(function() {
@@ -140,7 +140,7 @@
140140
- recconnect()
141141
*/
142142
this.$get = ['$timeout', '$log', function($timeout, $log) {
143-
var EventBusOriginal, EventBusStub, connect, debugEnabled, enabled, eventBus, prefix, reconnectEnabled, sockjsOptions, sockjsReconnectInterval, sockjsStateInterval, url, urlPath, urlServer, _ref;
143+
var EventBusOriginal, EventBusStub, connect, debugEnabled, disconnectTimeoutEnabled, enabled, eventBus, prefix, reconnectEnabled, sockjsOptions, sockjsReconnectInterval, sockjsStateInterval, url, urlPath, urlServer, _ref;
144144
_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;
145145
EventBusStub = null;
146146
EventBusOriginal = typeof vertx !== "undefined" && vertx !== null ? vertx.EventBus : void 0;
@@ -150,6 +150,7 @@
150150
$log.debug("[Vert.x EB Stub] Enabled: connecting '" + url + "'");
151151
}
152152
eventBus = null;
153+
disconnectTimeoutEnabled = true;
153154
connect = function() {
154155
eventBus = new EventBusOriginal(url, void 0, sockjsOptions);
155156
eventBus.onopen = function() {
@@ -161,21 +162,39 @@
161162
}
162163
};
163164
eventBus.onclose = function() {
164-
if (debugEnabled) {
165-
$log.debug("[Vert.x EB Stub] Reconnect in " + sockjsReconnectInterval + "ms");
166-
}
167165
if (typeof EventBusStub.onclose === 'function') {
168166
EventBusStub.onclose();
169167
}
170-
if (reconnectEnabled) {
171-
$timeout(connect, sockjsReconnectInterval);
168+
if (!disconnectTimeoutEnabled) {
169+
if (debugEnabled) {
170+
$log.debug("[Vert.x EB Stub] Reconnect immediately");
171+
}
172+
disconnectTimeoutEnabled = true;
173+
connect();
174+
} else {
175+
if (reconnectEnabled) {
176+
if (debugEnabled) {
177+
$log.debug("[Vert.x EB Stub] Reconnect in " + sockjsReconnectInterval + "ms");
178+
}
179+
$timeout(connect, sockjsReconnectInterval);
180+
}
172181
}
173182
};
174183
};
175184
connect();
176185
EventBusStub = {
177-
reconnect: function() {
178-
return eventBus.close();
186+
reconnect: function(immediately) {
187+
if (immediately == null) {
188+
immediately = false;
189+
}
190+
if (eventBus.readyState() === EventBusStub.EventBus.OPEN) {
191+
if (immediately) {
192+
disconnectTimeoutEnabled = false;
193+
}
194+
return eventBus.close();
195+
} else {
196+
return connect();
197+
}
179198
},
180199
close: function() {
181200
return eventBus.close();
@@ -528,22 +547,26 @@
528547
vertxEventBus.unregisterHandler(address, callbackMap.get(callback));
529548
callbackMap.remove(callback);
530549
},
531-
send: function(address, message, timeout) {
550+
send: function(address, message, timeout, expectReply) {
532551
var deferred, dispatched, next;
533552
if (timeout == null) {
534553
timeout = 10000;
535554
}
555+
if (expectReply == null) {
556+
expectReply = true;
557+
}
536558
deferred = $q.defer();
537559
next = function() {
538-
vertxEventBus.send(address, message, function(reply) {
539-
if (deferred) {
560+
if (expectReply) {
561+
vertxEventBus.send(address, message, function(reply) {
540562
return deferred.resolve(reply);
541-
}
542-
});
543-
if (deferred) {
563+
});
544564
return $interval((function() {
545565
return deferred.reject();
546566
}), timeout, 1);
567+
} else {
568+
vertxEventBus.send(address, message);
569+
return deferred.resolve();
547570
}
548571
};
549572
next.displayName = "" + CONSTANTS.MODULE + "/" + CONSTANTS.COMPONENT + ": util.send (ensureOpenAuthConnection callback)";
@@ -641,11 +664,14 @@
641664
return util.unregisterHandler(address, callback);
642665
}
643666
},
644-
send: function(address, message, timeout) {
667+
send: function(address, message, timeout, expectReply) {
645668
if (timeout == null) {
646669
timeout = 10000;
647670
}
648-
return util.send(address, message, timeout);
671+
if (expectReply == null) {
672+
expectReply = true;
673+
}
674+
return util.send(address, message, timeout, expectReply);
649675
},
650676
publish: function(address, message) {
651677
return util.publish(address, message);

0 commit comments

Comments
 (0)