[Router] gracefully set and do not reset the ol_context

This commit is contained in:
Jakob Ackermann 2020-04-21 12:45:23 +01:00
parent ce4f9148c3
commit d17ef183d0

View file

@ -55,7 +55,7 @@ module.exports = Router =
app.post "/client/:client_id/disconnect", httpAuth, HttpApiController.disconnectClient
session.on 'connection', (error, client, session) ->
client.ol_context = {}
client.ol_context = {} unless client.ol_context
client?.on "error", (err) ->
logger.err { clientErr: err }, "socket.io client error"
@ -113,13 +113,9 @@ module.exports = Router =
metrics.inc('socket-io.disconnect')
metrics.gauge('socket-io.clients', io.sockets.clients()?.length - 1)
cleanup = () ->
delete client.ol_context
WebsocketController.leaveProject io, client, (err) ->
if err?
Router._handleError cleanup, err, client, "leaveProject"
else
cleanup()
Router._handleError (() ->), err, client, "leaveProject"
# Variadic. The possible arguments:
# doc_id, callback