fix address sockets
This commit is contained in:
parent
786aaf43e0
commit
daf9234f85
@ -23,7 +23,7 @@ module.exports.broadcast_block = function(block) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
module.exports.broadcast_address_tx = function(address, tx) {
|
module.exports.broadcast_address_tx = function(address, tx) {
|
||||||
ios.sockets.in(address).emit('atx', tx);
|
ios.sockets.in(address).emit(address, tx);
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.broadcastSyncInfo = function(historicSync) {
|
module.exports.broadcastSyncInfo = function(historicSync) {
|
||||||
|
|||||||
@ -1,29 +1,39 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('insight.address').controller('AddressController',
|
angular.module('insight.address').controller('AddressController',
|
||||||
function ($scope, $rootScope, $routeParams, $location, Global, Address, get_socket) {
|
function($scope, $rootScope, $routeParams, $location, Global, Address, get_socket) {
|
||||||
$scope.global = Global;
|
$scope.global = Global;
|
||||||
|
|
||||||
$scope.findOne = function() {
|
$scope.findOne = function() {
|
||||||
Address.get({
|
Address.get({
|
||||||
addrStr: $routeParams.addrStr
|
addrStr: $routeParams.addrStr
|
||||||
}, function(address) {
|
},
|
||||||
$scope.address = address;
|
function(address) {
|
||||||
}, function(e) {
|
$scope.address = address;
|
||||||
if (e.status === 400) {
|
},
|
||||||
$rootScope.flashMessage = 'Invalid Address: ' + $routeParams.addrStr;
|
function(e) {
|
||||||
}
|
if (e.status === 400) {
|
||||||
else if (e.status === 503) {
|
$rootScope.flashMessage = 'Invalid Address: ' + $routeParams.addrStr;
|
||||||
$rootScope.flashMessage = 'Backend Error. ' + e.data;
|
}
|
||||||
}
|
else if (e.status === 503) {
|
||||||
else {
|
$rootScope.flashMessage = 'Backend Error. ' + e.data;
|
||||||
$rootScope.flashMessage = 'Address Not Found';
|
}
|
||||||
}
|
else {
|
||||||
$location.path('/');
|
$rootScope.flashMessage = 'Address Not Found';
|
||||||
});
|
}
|
||||||
};
|
$location.path('/');
|
||||||
var socket = get_socket($scope);
|
});
|
||||||
socket.emit('subscribe', $routeParams.addrStr);
|
};
|
||||||
|
var socket = get_socket($scope);
|
||||||
|
socket.emit('subscribe', $routeParams.addrStr);
|
||||||
|
socket.on($routeParams.addrStr, function(tx) {
|
||||||
|
console.log('atx ' + tx.txid);
|
||||||
|
var beep = new Audio('/sound/transaction.mp3');
|
||||||
|
beep.play();
|
||||||
|
$rootScope.$broadcast('tx', tx.txid);
|
||||||
|
});
|
||||||
|
|
||||||
$scope.params = $routeParams;
|
|
||||||
|
$scope.params = $routeParams;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('insight.transactions').controller('transactionsController',
|
angular.module('insight.transactions').controller('transactionsController',
|
||||||
function ($scope, $rootScope, $routeParams, $location, Global, Transaction, TransactionsByBlock, TransactionsByAddress, get_socket) {
|
function ($scope, $rootScope, $routeParams, $location, Global, Transaction, TransactionsByBlock, TransactionsByAddress) {
|
||||||
$scope.global = Global;
|
$scope.global = Global;
|
||||||
$scope.loading = false;
|
$scope.loading = false;
|
||||||
$scope.loadedBy = null;
|
$scope.loadedBy = null;
|
||||||
@ -144,14 +144,10 @@ angular.module('insight.transactions').controller('transactionsController',
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var socket = get_socket($scope);
|
|
||||||
socket.on('atx', function(tx) {
|
|
||||||
console.log('atx '+tx.txid);
|
|
||||||
var beep = new Audio('/sound/transaction.mp3');
|
|
||||||
beep.play();
|
|
||||||
$scope.findTx(tx.txid);
|
|
||||||
});
|
|
||||||
|
|
||||||
$scope.txs = [];
|
$scope.txs = [];
|
||||||
|
|
||||||
|
$scope.$on('tx', function(event, txid) {
|
||||||
|
$scope.findTx(txid);
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
@ -47,11 +47,13 @@ ScopedSocket.prototype.emit = function(event, data, callback) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
angular.module('insight.socket').factory('get_socket',
|
angular.module('insight.socket').factory('get_socket',
|
||||||
function($rootScope) {
|
function($rootScope) {
|
||||||
var socket = io.connect();
|
var socket = io.connect();
|
||||||
return function(scope) {
|
return function(scope) {
|
||||||
var scopedSocket = new ScopedSocket(socket, $rootScope);
|
var scopedSocket = new ScopedSocket(socket, $rootScope);
|
||||||
scope.$on('$destroy', function() {
|
scope.$on('$routeChangeStart', function() {
|
||||||
|
});
|
||||||
|
scope.$on('$destroy', function() {
|
||||||
scopedSocket.removeAllListeners();
|
scopedSocket.removeAllListeners();
|
||||||
});
|
});
|
||||||
return scopedSocket;
|
return scopedSocket;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user