update to socket.io 1.0, adds connection error warnings
This commit is contained in:
parent
d88ef95789
commit
3a4bb56c26
6 changed files with 75 additions and 13 deletions
|
|
@ -19,6 +19,7 @@
|
|||
"file-saver": "*",
|
||||
"qrcode-decoder-js": "*",
|
||||
"bitcore": "~0.1.19",
|
||||
"angular-moment": "~0.7.1"
|
||||
"angular-moment": "~0.7.1",
|
||||
"socket.io-client": ">=1.0.0"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
12
index.html
12
index.html
|
|
@ -82,6 +82,16 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row" ng-if='$root.insightError'>
|
||||
<div class="small-8 large-centered columns">
|
||||
<div data-alert class="alert-box radius error">
|
||||
Error connecting to Insight server. Check
|
||||
you settings and Internet connection.
|
||||
Trying to reconnect...
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row" ng-if='$root.$flashMessage.message' notification>
|
||||
<div class="small-8 large-centered columns">
|
||||
<div data-alert class="alert-box radius {{$root.$flashMessage.type}}">
|
||||
|
|
@ -782,7 +792,7 @@ on supported browsers please check <a href="http://www.webrtc.org/">http://www.w
|
|||
<script src="lib/crypto-js/rollups/pbkdf2.js"></script>
|
||||
<script src="lib/crypto-js/rollups/aes.js"></script>
|
||||
<script src="lib/file-saver/FileSaver.js"></script>
|
||||
<script src="lib/socket.io.js"></script>
|
||||
<script src="lib//socket.io-client/socket.io.js"></script>
|
||||
<script src="lib/sjcl.js"></script>
|
||||
<script src="lib/ios-imagefile-megapixel/megapix-image.js"></script>
|
||||
<script src="lib/qrcode-decoder-js/lib/qrcode-decoder.min.js"></script>
|
||||
|
|
|
|||
|
|
@ -33,14 +33,28 @@ angular.module('copayApp.controllers').controller('HeaderController',
|
|||
}
|
||||
});
|
||||
|
||||
|
||||
// Initialize alert notification (not show when init wallet)
|
||||
$rootScope.txAlertCount = 0;
|
||||
$rootScope.$watch('txAlertCount', function(txAlertCount) {
|
||||
if (txAlertCount && txAlertCount > 0) {
|
||||
$notification.info('New Transaction', ($rootScope.txAlertCount == 1) ? 'You have a pending transaction proposal' : 'You have ' + $rootScope.txAlertCount + ' pending transaction proposals', txAlertCount);
|
||||
}
|
||||
|
||||
$rootScope.$watch('blockChainStatus', function(status) {
|
||||
var h = config.blockchain.host + ':' + config.blockchain.port;
|
||||
if (status === 'error')
|
||||
$rootScope.insightError = 1;
|
||||
else
|
||||
if (status === 'restored') {
|
||||
$rootScope.insightError = 0;
|
||||
$rootScope.$flashMessage = {
|
||||
type: 'success',
|
||||
message: 'Networking Restored',
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Init socket handlers (with no wallet yet)
|
||||
controllerUtils.setSocketHandlers();
|
||||
|
||||
$rootScope.$watch('receivedFund', function(receivedFund) {
|
||||
if (receivedFund) {
|
||||
var currentAddr;
|
||||
|
|
@ -59,6 +73,14 @@ angular.module('copayApp.controllers').controller('HeaderController',
|
|||
}
|
||||
});
|
||||
|
||||
$rootScope.$watch('txAlertCount', function(txAlertCount) {
|
||||
if (txAlertCount && txAlertCount > 0) {
|
||||
$notification.info('New Transaction', ($rootScope.txAlertCount == 1) ? 'You have a pending transaction proposal' : 'You have ' + $rootScope.txAlertCount + ' pending transaction proposals', txAlertCount);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
$scope.isActive = function(item) {
|
||||
if (item.link && item.link.replace('#','') == $location.path()) {
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -174,7 +174,25 @@ angular.module('copayApp.services')
|
|||
$rootScope.pendingTxCount = pendingForUs;
|
||||
};
|
||||
|
||||
root._setCommError = function(e) {
|
||||
$rootScope.blockChainStatus='error';
|
||||
};
|
||||
|
||||
|
||||
root._clearCommError = function(e) {
|
||||
if ($rootScope.blockChainStatus==='error')
|
||||
$rootScope.blockChainStatus='restored';
|
||||
};
|
||||
|
||||
root.setSocketHandlers = function() {
|
||||
if (!Socket.sysEventsSet) {
|
||||
Socket.sysOn('error', root._setCommError);
|
||||
Socket.sysOn('reconnect_error', root._setCommError);
|
||||
Socket.sysOn('reconnect_failed', root._setCommError);
|
||||
Socket.sysOn('connect', root._clearCommError);
|
||||
Socket.sysOn('reconnect', root._clearCommError);
|
||||
Socket.sysEventsSet=true;
|
||||
}
|
||||
if (!$rootScope.wallet) return;
|
||||
|
||||
var currentAddrs= Socket.getListeners();
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ angular.module('notifications', []).
|
|||
info: { duration: 5000, enabled: true },
|
||||
funds: { duration: 5000, enabled: true },
|
||||
warning: { duration: 5000, enabled: true },
|
||||
error: { duration: 5000, enabled: true },
|
||||
error: { duration: 1e10, enabled: true },
|
||||
success: { duration: 5000, enabled: true },
|
||||
progress: { duration: 0, enabled: true },
|
||||
custom: { duration: 35000, enabled: true },
|
||||
|
|
|
|||
|
|
@ -4,9 +4,9 @@ angular.module('copayApp.services').factory('Socket',
|
|||
function($rootScope) {
|
||||
var listeners = [];
|
||||
var url = 'http://' + config.socket.host + ':' + config.socket.port;
|
||||
var socket = io.connect(url, {
|
||||
'reconnect': true,
|
||||
'reconnection delay': 500,
|
||||
var socket = io(url, {
|
||||
'reconnection': true,
|
||||
'reconnectionDelay': 500,
|
||||
});
|
||||
|
||||
return {
|
||||
|
|
@ -17,7 +17,6 @@ angular.module('copayApp.services').factory('Socket',
|
|||
callback.apply(socket, args);
|
||||
});
|
||||
};
|
||||
|
||||
socket.on(event, wrappedCallback);
|
||||
if (event !== 'connect') {
|
||||
listeners.push({
|
||||
|
|
@ -26,9 +25,21 @@ angular.module('copayApp.services').factory('Socket',
|
|||
});
|
||||
}
|
||||
},
|
||||
sysOn: function(event, callback) {
|
||||
var wrappedCallback = function() {
|
||||
var args = arguments;
|
||||
$rootScope.$apply(function() {
|
||||
callback.apply(socket, args);
|
||||
});
|
||||
};
|
||||
socket.io.on(event, wrappedCallback);
|
||||
},
|
||||
getListeners: function() {
|
||||
var ret = {};
|
||||
var addrList = listeners.map(function(i) {return i.event;});
|
||||
|
||||
var addrList = listeners
|
||||
.map(function(i) {return i.event;});
|
||||
|
||||
for (var i in addrList) {
|
||||
ret[addrList[i]] = 1;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue