fixing socket API

This commit is contained in:
Manuel Araoz 2014-01-20 14:30:25 -03:00
parent 76273d1c6c
commit 37d18b7b2d
3 changed files with 10 additions and 9 deletions

View File

@ -24,9 +24,10 @@ module.exports.broadcast_block = function(block) {
};
module.exports.broadcast_address_tx = function(address, tx) {
ios.sockets.in(address).emit('tx', tx);
console.log('sending address tx '+address+' '+tx);
ios.sockets.in(address).emit('atx', tx);
};
module.exports.broadcastSyncInfo = function(syncInfo) {
ios.sockets.emit('block', syncInfo);
ios.sockets.emit('status', syncInfo);
};

View File

@ -9,7 +9,8 @@ angular.module('insight.transactions').controller('transactionsController',
'Transaction',
'TransactionsByBlock',
'TransactionsByAddress',
function ($scope, $rootScope, $routeParams, $location, Global, Transaction, TransactionsByBlock, TransactionsByAddress) {
'get_socket',
function ($scope, $rootScope, $routeParams, $location, Global, Transaction, TransactionsByBlock, TransactionsByAddress, get_socket) {
$scope.global = Global;
$scope.findThis = function() {
@ -43,10 +44,12 @@ angular.module('insight.transactions').controller('transactionsController',
$scope.txs = txs;
});
};
/*socket.on('tx', function(tx) {
console.log('Incoming message for new transaction!', tx);
var socket = get_socket($scope);
console.log('transactions.js');
socket.on('atx', function(tx) {
console.log('Incoming transaction for address!', tx);
$scope.findTx(tx.txid);
});*/
});
$scope.txs = [];

View File

@ -7,10 +7,8 @@ var ScopedSocket = function(socket, $rootScope) {
};
ScopedSocket.prototype.removeAllListeners = function() {
console.log('remove all listeners');
for (var i = 0; i < this.listeners.length; i++) {
var details = this.listeners[i];
console.log('removing listener '+i);
this.socket.removeListener(details.event, details.fn);
}
this.listeners = [];
@ -20,7 +18,6 @@ ScopedSocket.prototype.on = function(event, callback) {
var socket = this.socket;
var $rootScope = this.$rootScope;
var wrapped_callback = function() {
var args = arguments;
$rootScope.$apply(function() {