 						callback(null, args...)
 
 			client.on "leaveDoc", (doc_id, callback) ->
+				if typeof callback != 'function'
+					return Router._handleInvalidArguments(client, 'leaveDoc', arguments)
+
 				WebsocketController.leaveDoc client, doc_id, (err, args...) ->
 					if err?
 						Router._handleError callback, err, client, "leaveDoc"

				logger.error attrs, "server side error in #{method}"
				# Don't return raw error to prevent leaking server side info
				return callback {message: "Something went wrong in real-time service"}

	configure: (app, io, session) ->
		app.set("io", io)

						callback()

			client.on "applyOtUpdate", (doc_id, update, callback = (error) ->) ->
				if typeof callback != 'function'
					return Router._handleInvalidArguments(client, 'applyOtUpdate', arguments)

				WebsocketController.applyOtUpdate client, doc_id, update, (err) ->
					if err?
						Router._handleError callback, err, client, "applyOtUpdate", {doc_id, update}
