Accept arrays of messages to send to client

This commit is contained in:
James Allen 2015-03-12 14:32:35 +00:00
parent 536118b0cf
commit 5da5c5c435

View file

@ -4,5 +4,9 @@ logger = require "logger-sharelatex"
module.exports = HttpApiController =
sendMessage: (req, res, next) ->
logger.log {message: req.params.message}, "sending message"
WebsocketLoadBalancer.emitToRoom req.params.project_id, req.params.message, req.body
if Array.isArray(req.body)
for payload in req.body
WebsocketLoadBalancer.emitToRoom req.params.project_id, req.params.message, payload
else
WebsocketLoadBalancer.emitToRoom req.params.project_id, req.params.message, req.body
res.send 204 # No content