|
|
@ -8,12 +8,11 @@ log.debug = log.verbose; |
|
|
|
var Uuid = require('uuid'); |
|
|
|
|
|
|
|
var WalletService = require('./server'); |
|
|
|
|
|
|
|
var Notification = require('./model/notification'); |
|
|
|
var MessageBroker = require('./messagebroker'); |
|
|
|
|
|
|
|
log.level = 'debug'; |
|
|
|
|
|
|
|
var io, messageQueue; |
|
|
|
var io, messageBroker; |
|
|
|
|
|
|
|
var WsApp = function() {}; |
|
|
|
|
|
|
@ -28,24 +27,16 @@ WsApp._handleNotification = function(notification) { |
|
|
|
|
|
|
|
WsApp.start = function(server, opts, cb) { |
|
|
|
opts = opts || {}; |
|
|
|
$.checkState(opts.messageQueueOpts); |
|
|
|
$.checkState(opts.messageBrokerOpts); |
|
|
|
|
|
|
|
io = require('socket.io')(server); |
|
|
|
|
|
|
|
async.series([ |
|
|
|
|
|
|
|
function(done) { |
|
|
|
messageQueue = require('socket.io-client').connect(opts.messageQueueOpts.url, { |
|
|
|
'force new connection': true, |
|
|
|
}); |
|
|
|
messageQueue.on('connect_error', function(err) { |
|
|
|
log.warn('Could not connect to message queue server'); |
|
|
|
}); |
|
|
|
messageQueue.on('notification', WsApp._handleNotification); |
|
|
|
|
|
|
|
messageQueue.on('connect', function() { |
|
|
|
done(); |
|
|
|
}); |
|
|
|
messageBroker = new MessageBroker(opts.messageBrokerOpts); |
|
|
|
messageBroker.onMessage(WsApp._handleNotification); |
|
|
|
done(); |
|
|
|
}, |
|
|
|
function(done) { |
|
|
|
io.on('connection', function(socket) { |
|
|
|