2014-01-13 13:13:41 -08:00
|
|
|
'use strict';
|
|
|
|
|
2014-01-14 10:20:59 -08:00
|
|
|
// server-side socket behaviour
|
2014-01-14 11:56:02 -08:00
|
|
|
|
2014-01-16 18:23:10 -08:00
|
|
|
// io is a variable already taken in express
|
|
|
|
var ios = null;
|
2014-01-14 11:56:02 -08:00
|
|
|
|
|
|
|
module.exports.init = function(app, io_ext) {
|
2014-01-16 18:23:10 -08:00
|
|
|
ios = io_ext;
|
|
|
|
ios.set('log level', 1); // reduce logging
|
|
|
|
ios.sockets.on('connection', function() {
|
2014-01-13 13:13:41 -08:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2014-01-14 11:56:02 -08:00
|
|
|
|
|
|
|
module.exports.broadcast_tx = function(tx) {
|
2014-01-16 18:23:10 -08:00
|
|
|
ios.sockets.emit('tx', tx);
|
2014-01-14 11:56:02 -08:00
|
|
|
};
|
2014-01-14 14:42:38 -08:00
|
|
|
|
|
|
|
|
|
|
|
module.exports.broadcast_block = function(block) {
|
2014-01-16 18:23:10 -08:00
|
|
|
ios.sockets.emit('block', block);
|
2014-01-14 14:42:38 -08:00
|
|
|
};
|