support for the new connector version

This commit is contained in:
DadaMonad
2015-01-04 02:20:12 +00:00
parent 17a752c93e
commit d2fa906b50
8 changed files with 106 additions and 34 deletions

View File

@@ -14,9 +14,16 @@ adaptConnector = (connector, engine, HB, execution_listener)->
sendStateVector = ()->
HB.getOperationCounter()
sendHb = (state_vector)->
HB._encode(state_vector)
json = HB._encode(state_vector)
if json.length > 0
json
else
null
applyHb = (hb)->
engine.applyOpsCheckDouble hb
if hb?
engine.applyOpsCheckDouble hb
else
null
connector.whenSyncing sendStateVector, sendHb, applyHb
connector.whenReceiving (sender, op)->

View File

@@ -18,15 +18,20 @@ class HistoryBuffer
@garbage = [] # Will be cleaned on next call of garbageCollector
@trash = [] # Is deleted. Wait until it is not used anymore.
@performGarbageCollection = true
@garbageCollectTimeout = 1000
@garbageCollectTimeout = 30000
@reserved_identifier_counter = 0
setTimeout @emptyGarbage, @garbageCollectTimeout
resetUserId: (id)->
own = @buffer[@user_id]
if own?
for o in own
for o_name,o of own
o.uid.creator = id
if @buffer[id]?
throw new Error "You are re-assigning an old user id - this is not (yet) possible!"
@buffer[id] = own
delete @buffer[@user_id]
@operation_counter[id] = @operation_counter[@user_id]
delete @operation_counter[@user_id]
@user_id = id