Change to use bitcoind/addresstxid event

This commit is contained in:
Braydon Fuller 2016-05-17 20:17:04 -04:00
parent 923c596b74
commit 3532cd25a1
2 changed files with 6 additions and 3 deletions

View File

@ -8,12 +8,12 @@ angular.module('insight.address').controller('AddressController',
var socket = getSocket($scope);
var _startSocket = function () {
socket.emit('subscribe', $routeParams.addrStr);
socket.on($routeParams.addrStr, function(tx) {
socket.on('bitcoind/addresstxid', function(tx) {
$rootScope.$broadcast('tx', tx);
var beep = new Audio('/sound/transaction.mp3');
beep.play();
});
socket.emit('subscribe', 'bitcoind/addresstxid', [$routeParams.addrStr]);
};
socket.on('connect', function() {

View File

@ -39,8 +39,9 @@ ScopedSocket.prototype.on = function(event, callback) {
ScopedSocket.prototype.emit = function(event, data, callback) {
var socket = this.socket;
var $rootScope = this.$rootScope;
var args = Array.prototype.slice.call(arguments);
socket.emit(event, data, function() {
args.push(function() {
var args = arguments;
$rootScope.$apply(function() {
if (callback) {
@ -48,6 +49,8 @@ ScopedSocket.prototype.emit = function(event, data, callback) {
}
});
});
socket.emit.apply(socket, args);
};
angular.module('insight.socket').factory('getSocket',