configurable websocket server

master
Juanfran 2015-02-16 10:56:20 +01:00
parent b23226b30d
commit 9bf956644f
2 changed files with 5 additions and 2 deletions

View File

@ -7,5 +7,8 @@
"queue": {
"name": "EventsPushBackend",
"options": {}
},
"webSocketServer": {
"port": 3000
}
}

View File

@ -7,7 +7,7 @@ clients = require('./clients')
connection = amqp.createConnection({ url: config.url }, {defaultExchangeName: config.exchange.name})
WebSocketServer = require('ws').Server
wss = new WebSocketServer({ port: 3000 })
wss = new WebSocketServer(config.webSocketServer)
connection.on 'ready', () ->
connection.queue config.queue.name, config.queue.options, (q) ->
@ -30,7 +30,7 @@ connection.on 'ready', () ->
clientMsgStr = JSON.stringify(clientMsg)
subscriptions.forEach (client) ->
#excude sender client
#exclude sender client
if !senderClient || client.id != senderClient.id
client.ws.send clientMsgStr