configurable websocket server
parent
b23226b30d
commit
9bf956644f
|
@ -7,5 +7,8 @@
|
||||||
"queue": {
|
"queue": {
|
||||||
"name": "EventsPushBackend",
|
"name": "EventsPushBackend",
|
||||||
"options": {}
|
"options": {}
|
||||||
|
},
|
||||||
|
"webSocketServer": {
|
||||||
|
"port": 3000
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ clients = require('./clients')
|
||||||
connection = amqp.createConnection({ url: config.url }, {defaultExchangeName: config.exchange.name})
|
connection = amqp.createConnection({ url: config.url }, {defaultExchangeName: config.exchange.name})
|
||||||
|
|
||||||
WebSocketServer = require('ws').Server
|
WebSocketServer = require('ws').Server
|
||||||
wss = new WebSocketServer({ port: 3000 })
|
wss = new WebSocketServer(config.webSocketServer)
|
||||||
|
|
||||||
connection.on 'ready', () ->
|
connection.on 'ready', () ->
|
||||||
connection.queue config.queue.name, config.queue.options, (q) ->
|
connection.queue config.queue.name, config.queue.options, (q) ->
|
||||||
|
@ -30,7 +30,7 @@ connection.on 'ready', () ->
|
||||||
clientMsgStr = JSON.stringify(clientMsg)
|
clientMsgStr = JSON.stringify(clientMsg)
|
||||||
|
|
||||||
subscriptions.forEach (client) ->
|
subscriptions.forEach (client) ->
|
||||||
#excude sender client
|
#exclude sender client
|
||||||
if !senderClient || client.id != senderClient.id
|
if !senderClient || client.id != senderClient.id
|
||||||
client.ws.send clientMsgStr
|
client.ws.send clientMsgStr
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue