mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
21 lines
No EOL
753 B
CoffeeScript
21 lines
No EOL
753 B
CoffeeScript
WebsocketLoadBalancer = require "./WebsocketLoadBalancer"
|
|
DrainManager = require "./DrainManager"
|
|
logger = require "logger-sharelatex"
|
|
|
|
module.exports = HttpApiController =
|
|
sendMessage: (req, res, next) ->
|
|
logger.log {message: req.params.message}, "sending message"
|
|
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
|
|
|
|
startDrain: (req, res, next) ->
|
|
io = req.app.get("io")
|
|
rate = req.query.rate or "4"
|
|
rate = parseInt(rate, 10)
|
|
logger.log {rate}, "setting client drain rate"
|
|
DrainManager.startDrain io, rate
|
|
res.send 204 |