Skip to content

Commit

Permalink
chore: dist
Browse files Browse the repository at this point in the history
  • Loading branch information
JaimeBeneytez committed Dec 15, 2015
1 parent a2179c7 commit 7d1169b
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 23 deletions.
54 changes: 32 additions & 22 deletions dist/ngAutobahn.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* ngAutobahn - v0.0.7 - 2015-12-08
* ngAutobahn - v0.0.7 - 2015-12-15
* https://github.com/ef-ctx/ngAutobahn
*
* Copyright (c) 2015 EF CTX <http://efclass.io>
Expand Down Expand Up @@ -435,7 +435,7 @@

$rootScope.$on(NG_AUTOBAHN_CONNECTION_EVENTS.OPEN, connectionOpenedHandler);
$rootScope.$on(NG_AUTOBAHN_CONNECTION_EVENTS.CLOSE, connectionClosedHandler);
$rootScope.$on(NG_AUTOBAHN_CONNECTION_EVENTS.LOST, connectionClosedHandler);
$rootScope.$on(NG_AUTOBAHN_CONNECTION_EVENTS.LOST, connectionLostHandler);

/****************************************************************
* SUBSCRIBE
Expand Down Expand Up @@ -478,7 +478,7 @@
}
}

function subscribeHandlers() {
function _subscribeHandlers() {
for (var brokerId in _brokers) {
var broker = _brokers[brokerId];
_subscribeBroker(broker);
Expand Down Expand Up @@ -507,8 +507,8 @@
***************************************************************/
function connectionOpenedHandler(evt, session) {
if (!_session) {
_session = session;
subscribeHandlers();
_setSession(session);
_subscribeHandlers();
}
}

Expand All @@ -517,6 +517,10 @@
_session = null;
}

function connectionLostHandler(evt, reason) {
_session = null;
}

/****************************************************************
* REMOTE CALL
***************************************************************/
Expand Down Expand Up @@ -778,42 +782,48 @@
'$timeout',
'$interval',
function NgAutobahnPingFactory($timeout, $interval) {

return NgAutobahnPing;

function NgAutobahnPing(pingFn, errorFn) {
var self = this,
_timeout,
var _isPingPromiseResolved = true,
_interval;

self.start = start;
self.stop = stop;
this.start = start;
this.stop = stop;

function start() {
stop();
sendPingMessage();
_interval = $interval(sendPingMessage, config.delay, 0, false);
_interval = $interval(_intervalHandler, config.maxResponseDelay, 0, false);
}

function _intervalHandler() {
if (_isPingPromiseResolved) {
_invokePingFn();
} else {
_clearInterval();
_invokeErrorFn();
}
}

function stop() {
clearTimeout();
clearInterval();
_clearInterval();
_isPingPromiseResolved = true;
}

function sendPingMessage() {
_timeout = $timeout(_maxResponseDelayReachedHandler, config.maxResponseDelay);
pingFn().then(clearTimeout);
function _invokePingFn() {
_isPingPromiseResolved = false;
pingFn().then(_pingFunctionResolvedHandler);
}

function _maxResponseDelayReachedHandler() {
stop();
function _invokeErrorFn() {
errorFn();
}

function clearTimeout() {
$timeout.cancel(_timeout);
function _pingFunctionResolvedHandler() {
_isPingPromiseResolved = true;
}

function clearInterval() {
function _clearInterval() {
$interval.cancel(_interval);
}
}
Expand Down
2 changes: 1 addition & 1 deletion dist/ngAutobahn.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7d1169b

Please sign in to comment.