mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2025-07-25 11:00:07 +02:00

* [history-v1-ot] initial implementation of using doc-level history-v1-ot * [web] fix advancing of the otMigrationStage Use 'nextStage' for the user provided, desired stage when advancing. Co-authored-by: Brian Gough <brian.gough@overleaf.com> * [document-updater] document size check in editor-core * [history-ot] rename history-v1-ot to history-ot and add types * [history-ot] apply review feedback - remove extra !! - merge variable assignment when processing diff-match-match output - add helper function for getting docstore lines view of StringFileData Co-authored-by: Alf Eaton <alf.eaton@overleaf.com> * Revert "[document-updater] add safe rollback point for history-ot (#25283)" This reverts commit d7230dd14a379a27d2c6ab03a006463a18979d06 Signed-off-by: Jakob Ackermann <jakob.ackermann@overleaf.com> --------- Signed-off-by: Jakob Ackermann <jakob.ackermann@overleaf.com> Co-authored-by: Brian Gough <brian.gough@overleaf.com> Co-authored-by: Alf Eaton <alf.eaton@overleaf.com> GitOrigin-RevId: 89c497782adb0427635d50d02263d6f535b12481
64 lines
1.8 KiB
JavaScript
64 lines
1.8 KiB
JavaScript
const WebsocketLoadBalancer = require('./WebsocketLoadBalancer')
|
|
const DrainManager = require('./DrainManager')
|
|
const ConnectedUsersManager = require('./ConnectedUsersManager')
|
|
const logger = require('@overleaf/logger')
|
|
|
|
module.exports = {
|
|
countConnectedClients(req, res) {
|
|
const { projectId } = req.params
|
|
ConnectedUsersManager.countConnectedClients(
|
|
projectId,
|
|
(err, nConnectedClients) => {
|
|
if (err) {
|
|
logger.err({ err, projectId }, 'count connected clients failed')
|
|
return res.sendStatus(500)
|
|
}
|
|
res.json({ nConnectedClients })
|
|
}
|
|
)
|
|
},
|
|
|
|
sendMessage(req, res) {
|
|
logger.debug({ message: req.params.message }, 'sending message')
|
|
if (Array.isArray(req.body)) {
|
|
for (const payload of 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.sendStatus(204)
|
|
},
|
|
|
|
startDrain(req, res) {
|
|
const io = req.app.get('io')
|
|
let rate = req.query.rate || '4'
|
|
rate = parseFloat(rate) || 0
|
|
logger.info({ rate }, 'setting client drain rate')
|
|
DrainManager.startDrain(io, rate)
|
|
res.sendStatus(204)
|
|
},
|
|
|
|
disconnectClient(req, res, next) {
|
|
const io = req.app.get('io')
|
|
const { client_id: clientId } = req.params
|
|
const client = io.sockets.sockets[clientId]
|
|
|
|
if (!client) {
|
|
logger.debug({ clientId }, 'api: client already disconnected')
|
|
res.sendStatus(404)
|
|
return
|
|
}
|
|
logger.info({ clientId }, 'api: requesting client disconnect')
|
|
client.on('disconnect', () => res.sendStatus(204))
|
|
client.disconnect()
|
|
},
|
|
}
|