fixing double late join test fail

This commit is contained in:
DadaMonad
2015-02-17 19:23:27 +00:00
parent f609c22be8
commit 77b83cae2a
23 changed files with 225 additions and 166 deletions

View File

@@ -10,7 +10,7 @@ adaptConnector = function(connector, engine, HB, execution_listener) {
}
connector.setIsBoundToY();
send_ = function(o) {
if ((o.uid.creator === HB.getUserId()) && (typeof o.uid.op_number !== "string") && (o.uid.doSync === "true" || o.uid.doSync === true) && (HB.getUserId() !== "_temp")) {
if ((o.uid.creator === HB.getUserId()) && (typeof o.uid.op_number !== "string") && (HB.getUserId() !== "_temp")) {
return connector.broadcast(o);
}
};

View File

@@ -105,13 +105,13 @@ module.exports = {
/*
* Broadcast a message to all connected peers.
* @param message {Object} The message to broadcast.
*
#
broadcast: (message)->
throw new Error "You must implement broadcast!"
*
#
* Send a message to a peer, or set of peers
*
#
send: (peer_s, message)->
throw new Error "You must implement send!"
*/

View File

@@ -13,9 +13,9 @@ if (typeof window !== "undefined" && window !== null) {
}
Engine = (function() {
function Engine(HB, types) {
this.HB = HB;
this.types = types;
function Engine(_at_HB, _at_types) {
this.HB = _at_HB;
this.types = _at_types;
this.unprocessed_ops = [];
}
@@ -73,6 +73,7 @@ Engine = (function() {
op_json.fromHB = "true";
}
o = this.parseOperation(op_json);
o.parsed_from_json = op_json;
if (op_json.fromHB != null) {
o.fromHB = op_json.fromHB;
}

View File

@@ -2,8 +2,8 @@ var HistoryBuffer,
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
HistoryBuffer = (function() {
function HistoryBuffer(user_id) {
this.user_id = user_id;
function HistoryBuffer(_at_user_id) {
this.user_id = _at_user_id;
this.emptyGarbage = __bind(this.emptyGarbage, this);
this.operation_counter = {};
this.buffer = {};
@@ -92,15 +92,14 @@ HistoryBuffer = (function() {
return this.garbageCollectTimeoutId = void 0;
};
HistoryBuffer.prototype.setGarbageCollectTimeout = function(garbageCollectTimeout) {
this.garbageCollectTimeout = garbageCollectTimeout;
HistoryBuffer.prototype.setGarbageCollectTimeout = function(_at_garbageCollectTimeout) {
this.garbageCollectTimeout = _at_garbageCollectTimeout;
};
HistoryBuffer.prototype.getReservedUniqueIdentifier = function() {
return {
creator: '_',
op_number: "_" + (this.reserved_identifier_counter++),
doSync: false
op_number: "_" + (this.reserved_identifier_counter++)
};
};
@@ -143,9 +142,12 @@ HistoryBuffer = (function() {
_ref = this.buffer;
for (u_name in _ref) {
user = _ref[u_name];
if (u_name === "_") {
continue;
}
for (o_number in user) {
o = user[o_number];
if ((o.uid.noOperation == null) && o.uid.doSync && unknown(u_name, o_number)) {
if ((o.uid.noOperation == null) && unknown(u_name, o_number)) {
o_json = o._encode();
if (o.next_cl != null) {
o_next = o.next_cl;
@@ -177,8 +179,7 @@ HistoryBuffer = (function() {
}
uid = {
'creator': user_id,
'op_number': this.operation_counter[user_id],
'doSync': true
'op_number': this.operation_counter[user_id]
};
this.operation_counter[user_id]++;
return uid;
@@ -238,15 +239,18 @@ HistoryBuffer = (function() {
};
HistoryBuffer.prototype.addToCounter = function(o) {
if (this.operation_counter[o.uid.creator] == null) {
this.operation_counter[o.uid.creator] = 0;
var _base, _name;
if ((_base = this.operation_counter)[_name = o.uid.creator] == null) {
_base[_name] = 0;
}
if (typeof o.uid.op_number === 'number' && o.uid.creator !== this.getUserId()) {
if (o.uid.creator !== this.getUserId()) {
if (o.uid.op_number === this.operation_counter[o.uid.creator]) {
return this.operation_counter[o.uid.creator]++;
} else {
return this.invokeSync(o.uid.creator);
this.operation_counter[o.uid.creator]++;
}
while (this.buffer[o.uid.creator][this.operation_counter[o.uid.creator]] != null) {
this.operation_counter[o.uid.creator]++;
}
return void 0;
}
};

View File

@@ -1,6 +1,6 @@
var __slice = [].slice,
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
__hasProp = {}.hasOwnProperty;
module.exports = function(HB) {
var execution_listener, types;
@@ -79,8 +79,8 @@ module.exports = function(HB) {
return this.deleteAllObservers();
};
Operation.prototype.setParent = function(parent) {
this.parent = parent;
Operation.prototype.setParent = function(_at_parent) {
this.parent = _at_parent;
};
Operation.prototype.getParent = function() {
@@ -95,7 +95,6 @@ module.exports = function(HB) {
if (this.uid.alt != null) {
map_uid = this.uid.alt.cloneUid();
map_uid.sub = this.uid.sub;
map_uid.doSync = false;
return map_uid;
} else {
return void 0;
@@ -114,10 +113,6 @@ module.exports = function(HB) {
return uid;
};
Operation.prototype.dontSync = function() {
return this.uid.doSync = false;
};
Operation.prototype.execute = function() {
var l, _i, _len;
this.is_executed = true;
@@ -135,7 +130,7 @@ module.exports = function(HB) {
};
Operation.prototype.saveOperation = function(name, op) {
if ((op != null ? op.execute : void 0) != null) {
if (((op != null ? op.execute : void 0) != null) || typeof op === "string") {
return this[name] = op;
} else if (op != null) {
if (this.unchecked == null) {
@@ -296,6 +291,8 @@ module.exports = function(HB) {
this.prev_cl = this.parent.beginning;
}
if (this.origin == null) {
this.origin = this.prev_cl;
} else if (this.origin === "Delimiter") {
this.origin = this.parent.beginning;
}
if (this.next_cl == null) {
@@ -389,8 +386,8 @@ module.exports = function(HB) {
types.ImmutableObject = (function(_super) {
__extends(ImmutableObject, _super);
function ImmutableObject(uid, content) {
this.content = content;
function ImmutableObject(uid, _at_content) {
this.content = _at_content;
ImmutableObject.__super__.constructor.call(this, uid);
}

View File

@@ -1,6 +1,6 @@
var text_types_uninitialized,
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
__hasProp = {}.hasOwnProperty;
text_types_uninitialized = require("./TextTypes");

View File

@@ -1,6 +1,6 @@
var basic_types_uninitialized,
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
__hasProp = {}.hasOwnProperty;
basic_types_uninitialized = require("./BasicTypes");
@@ -159,9 +159,9 @@ module.exports = function(HB) {
types.ReplaceManager = (function(_super) {
__extends(ReplaceManager, _super);
function ReplaceManager(event_properties, event_this, uid, beginning, end) {
this.event_properties = event_properties;
this.event_this = event_this;
function ReplaceManager(_at_event_properties, _at_event_this, uid, beginning, end) {
this.event_properties = _at_event_properties;
this.event_this = _at_event_this;
if (this.event_properties['object'] == null) {
this.event_properties['object'] = this.event_this;
}
@@ -326,10 +326,14 @@ module.exports = function(HB) {
'parent': this.parent.getUid(),
'prev': this.prev_cl.getUid(),
'next': this.next_cl.getUid(),
'origin': this.origin.getUid(),
'uid': this.getUid(),
'is_deleted': this.is_deleted
};
if (this.origin.type === "Delimiter") {
json.origin = "Delimiter";
} else if (this.origin !== this.prev_cl) {
json.origin = this.origin.getUid();
}
if (this.content instanceof types.Operation) {
json['content'] = this.content.getUid();
} else {

View File

@@ -1,6 +1,6 @@
var structured_types_uninitialized,
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
__hasProp = {}.hasOwnProperty;
structured_types_uninitialized = require("./StructuredTypes");

View File

@@ -1,6 +1,6 @@
var Engine, HistoryBuffer, adaptConnector, createY, json_types_uninitialized,
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
__hasProp = {}.hasOwnProperty;
json_types_uninitialized = require("./Types/JsonTypes");