|
@@ -116,6 +116,26 @@ define [
|
|
|
flush: () ->
|
|
flush: () ->
|
|
|
@doc?.flushPendingOps()
|
|
@doc?.flushPendingOps()
|
|
|
|
|
|
|
|
|
|
+ chaosMonkey: (line = 0, char = "a") ->
|
|
|
|
|
+ orig = char
|
|
|
|
|
+ copy = null
|
|
|
|
|
+ pos = 0
|
|
|
|
|
+ timer = () =>
|
|
|
|
|
+ unless copy? and copy.length
|
|
|
|
|
+ copy = orig.slice() + ' ' + new Date() + '\n'
|
|
|
|
|
+ line += if Math.random() > 0.1 then 1 else -2
|
|
|
|
|
+ line = 0 if line < 0
|
|
|
|
|
+ pos = 0
|
|
|
|
|
+ char = copy[0]
|
|
|
|
|
+ copy = copy.slice(1)
|
|
|
|
|
+ @ace.session.insert({row: line, column: pos}, char)
|
|
|
|
|
+ pos += 1
|
|
|
|
|
+ @_cm = setTimeout timer, 100 + if Math.random() < 0.1 then 1000 else 0
|
|
|
|
|
+ @_cm = timer()
|
|
|
|
|
+
|
|
|
|
|
+ clearChaosMonkey: () ->
|
|
|
|
|
+ clearTimeout @_cm
|
|
|
|
|
+
|
|
|
pollSavedStatus: () ->
|
|
pollSavedStatus: () ->
|
|
|
# returns false if doc has ops waiting to be acknowledged or
|
|
# returns false if doc has ops waiting to be acknowledged or
|
|
|
# sent that haven't changed since the last time we checked.
|
|
# sent that haven't changed since the last time we checked.
|