mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-29 07:23:43 -05:00
[HttpApiController] implement the disconnection of a single client
The http route returns as soon as the client has fully disconnected.
This commit is contained in:
parent
91e296533f
commit
de35fc5ecf
2 changed files with 16 additions and 1 deletions
|
@ -19,3 +19,17 @@ module.exports = HttpApiController =
|
||||||
logger.log {rate}, "setting client drain rate"
|
logger.log {rate}, "setting client drain rate"
|
||||||
DrainManager.startDrain io, rate
|
DrainManager.startDrain io, rate
|
||||||
res.send 204
|
res.send 204
|
||||||
|
|
||||||
|
disconnectClient: (req, res, next) ->
|
||||||
|
io = req.app.get("io")
|
||||||
|
client_id = req.params.client_id
|
||||||
|
client = io.sockets.sockets[client_id]
|
||||||
|
|
||||||
|
if !client
|
||||||
|
logger.info({client_id}, "api: client already disconnected")
|
||||||
|
res.sendStatus(404)
|
||||||
|
return
|
||||||
|
logger.warn({client_id}, "api: requesting client disconnect")
|
||||||
|
client.on "disconnect", () ->
|
||||||
|
res.sendStatus(204)
|
||||||
|
client.disconnect()
|
||||||
|
|
|
@ -53,6 +53,7 @@ module.exports = Router =
|
||||||
app.post "/project/:project_id/message/:message", httpAuth, bodyParser.json(limit: "5mb"), HttpApiController.sendMessage
|
app.post "/project/:project_id/message/:message", httpAuth, bodyParser.json(limit: "5mb"), HttpApiController.sendMessage
|
||||||
|
|
||||||
app.post "/drain", httpAuth, HttpApiController.startDrain
|
app.post "/drain", httpAuth, HttpApiController.startDrain
|
||||||
|
app.post "/client/:client_id/disconnect", httpAuth, HttpApiController.disconnectClient
|
||||||
|
|
||||||
session.on 'connection', (error, client, session) ->
|
session.on 'connection', (error, client, session) ->
|
||||||
client?.on "error", (err) ->
|
client?.on "error", (err) ->
|
||||||
|
|
Loading…
Reference in a new issue