Ivan Socolsky
10 years ago
7 changed files with 64 additions and 54 deletions
@ -1,19 +0,0 @@ |
|||
#!/usr/bin/env node
|
|||
|
|||
'use strict'; |
|||
|
|||
var _ = require('lodash'); |
|||
var io = require('socket.io'); |
|||
|
|||
var DEFAULT_PORT = 3380; |
|||
|
|||
var port = parseInt(process.argv[2]) || DEFAULT_PORT; |
|||
|
|||
var server = io(port); |
|||
server.on('connection', function(socket) { |
|||
socket.on('notification', function(data) { |
|||
server.emit('notification', data); |
|||
}); |
|||
}); |
|||
|
|||
console.log('Message queue server listening on port ' + port) |
@ -0,0 +1,23 @@ |
|||
'use strict'; |
|||
|
|||
var $ = require('preconditions').singleton(); |
|||
var io = require('socket.io'); |
|||
var log = require('npmlog'); |
|||
log.debug = log.verbose; |
|||
|
|||
var MessageQueue = function() {}; |
|||
|
|||
MessageQueue.start = function(opts, cb) { |
|||
opts = opts || {}; |
|||
$.checkIsNumber(opts.port, 'Invalid port number'); |
|||
|
|||
var server = io(opts.port); |
|||
server.on('connection', function(socket) { |
|||
socket.on('notification', function(data) { |
|||
server.emit('notification', data); |
|||
}); |
|||
}); |
|||
return cb(); |
|||
}; |
|||
|
|||
module.exports = MessageQueue; |
@ -0,0 +1,16 @@ |
|||
#!/usr/bin/env node
|
|||
|
|||
'use strict'; |
|||
|
|||
var MQ = require('../lib/messagequeue'); |
|||
|
|||
var DEFAULT_PORT = 3380; |
|||
|
|||
var opts = { |
|||
port: parseInt(process.argv[2]) || DEFAULT_PORT, |
|||
}; |
|||
|
|||
MQ.start(opts, function(err) { |
|||
if (err) throw err; |
|||
console.log('Message queue server listening on port ' + port) |
|||
}); |
Loading…
Reference in new issue