|
@@ -51,23 +51,14 @@ module.exports = WebsocketController =
|
|
|
# is determined by FLUSH_IF_EMPTY_DELAY.
|
|
# is determined by FLUSH_IF_EMPTY_DELAY.
|
|
|
FLUSH_IF_EMPTY_DELAY: 500 #ms
|
|
FLUSH_IF_EMPTY_DELAY: 500 #ms
|
|
|
leaveProject: (io, client, callback = (error) ->) ->
|
|
leaveProject: (io, client, callback = (error) ->) ->
|
|
|
- metrics.inc "editor.leave-project"
|
|
|
|
|
Utils.getClientAttributes client, ["project_id", "user_id"], (error, {project_id, user_id}) ->
|
|
Utils.getClientAttributes client, ["project_id", "user_id"], (error, {project_id, user_id}) ->
|
|
|
return callback(error) if error?
|
|
return callback(error) if error?
|
|
|
|
|
+ return callback() unless project_id # client did not join project
|
|
|
|
|
|
|
|
|
|
+ metrics.inc "editor.leave-project"
|
|
|
logger.log {project_id, user_id, client_id: client.id}, "client leaving project"
|
|
logger.log {project_id, user_id, client_id: client.id}, "client leaving project"
|
|
|
WebsocketLoadBalancer.emitToRoom project_id, "clientTracking.clientDisconnected", client.id
|
|
WebsocketLoadBalancer.emitToRoom project_id, "clientTracking.clientDisconnected", client.id
|
|
|
|
|
|
|
|
- # bail out if the client had not managed to authenticate or join
|
|
|
|
|
- # the project. Prevents downstream errors in docupdater from
|
|
|
|
|
- # flushProjectToMongoAndDelete with null project_id.
|
|
|
|
|
- if not user_id?
|
|
|
|
|
- logger.log {client_id: client.id}, "client leaving, unknown user"
|
|
|
|
|
- return callback()
|
|
|
|
|
- if not project_id?
|
|
|
|
|
- logger.log {user_id: user_id, client_id: client.id}, "client leaving, not in project"
|
|
|
|
|
- return callback()
|
|
|
|
|
-
|
|
|
|
|
# We can do this in the background
|
|
# We can do this in the background
|
|
|
ConnectedUsersManager.markUserAsDisconnected project_id, client.id, (err) ->
|
|
ConnectedUsersManager.markUserAsDisconnected project_id, client.id, (err) ->
|
|
|
if err?
|
|
if err?
|