Sfoglia il codice sorgente

Handle options not being passed

Alasdair Smith 9 anni fa
parent
commit
b796879c9f
1 ha cambiato i file con 15 aggiunte e 1 eliminazioni
  1. 15 1
      services/real-time/app/coffee/Router.coffee

+ 15 - 1
services/real-time/app/coffee/Router.coffee

@@ -79,8 +79,22 @@ module.exports = Router =
 					if err?
 					if err?
 						Router._handleError null, err, client, "leaveProject"
 						Router._handleError null, err, client, "leaveProject"
 
 
-
+			# Variadic. The possible options:
+			# doc_id, callback
+			# doc_id, fromVersion, callback
+			# doc_id, options, callback
+			# doc_id, options, fromVersion, callback
 			client.on "joinDoc", (doc_id, options, fromVersion, callback) ->
 			client.on "joinDoc", (doc_id, options, fromVersion, callback) ->
+				# options is optional
+				if typeof options == "function"
+					options = {}
+					callback = options
+					fromVersion = -1
+				else if typeof options == "number"
+					options = {}
+					fromVersion = options
+					callback = fromVersion
+
 				# fromVersion is optional
 				# fromVersion is optional
 				if typeof fromVersion == "function"
 				if typeof fromVersion == "function"
 					callback = fromVersion
 					callback = fromVersion