From 5da5c5c4354e9f5e75a4ad3c929c3033425d62c3 Mon Sep 17 00:00:00 2001 From: James Allen Date: Thu, 12 Mar 2015 14:32:35 +0000 Subject: [PATCH] Accept arrays of messages to send to client --- services/real-time/app/coffee/HttpApiController.coffee | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/services/real-time/app/coffee/HttpApiController.coffee b/services/real-time/app/coffee/HttpApiController.coffee index faa06b9822..1082a11b34 100644 --- a/services/real-time/app/coffee/HttpApiController.coffee +++ b/services/real-time/app/coffee/HttpApiController.coffee @@ -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 \ No newline at end of file