fixed late join issues, and null on event
This commit is contained in:
parent
b750d95b98
commit
4da6efd634
2
build/browser/Connectors/IwcConnector.min.js
vendored
2
build/browser/Connectors/IwcConnector.min.js
vendored
@ -1 +1 @@
|
||||
!function t(n,e,r){function i(u,a){if(!e[u]){if(!n[u]){var s="function"==typeof require&&require;if(!a&&s)return s(u,!0);if(o)return o(u,!0);throw new Error("Cannot find module '"+u+"'")}var c=e[u]={exports:{}};n[u][0].call(c.exports,function(t){var e=n[u][1][t];return i(e?e:t)},c,c.exports,t,n,e,r)}return e[u].exports}for(var o="function"==typeof require&&require,u=0;u<r.length;u++)i(r[u]);return i}({1:[function(t,n){var e;e=function(t,n){var e,r,i,o,u,a;return a=null,null!=n&&(a=n.iwcHandler),o={},r=new DUIClient,r.connect(function(t){var n;return null!=(n=o[t.action])&&n.map(function(n){return setTimeout(function(){return n(t)},0)}),null!=a?a(t):void 0}),r.initOK(),u=null,e=function(){function t(t,n,e,i){var a,s,c,l;this.engine=t,this.HB=n,this.execution_listener=e,this.yatta=i,this.duiClient=r,this.iwcHandler=o,l=function(t){return function(n){return 0!==Object.getOwnPropertyNames(t.initialized).length?t.send(n):void 0}}(this),this.execution_listener.push(l),this.initialized={},a=function(t){return function(e){var r;return n=e.extras.HB,r=e.extras.user,t.engine.applyOpsCheckDouble(n),t.initialized[r]=!0}}(this),o.Yatta_push_HB_element=[a],this.sendIwcIntent("Yatta_get_HB_element",this.HB.getOperationCounter()),s=function(t){return function(n){var e;return e=n.extras,null!=t.initialized[e.uid.creator]?t.receive(e):void 0}}(this),this.iwcHandler.Yatta_new_operation=[s],null!=u&&this.engine.applyOpsCheckDouble(u),c=function(t){return function(n){var e,r;return r=n.extras,console.log(r),e={HB:t.yatta.getHistoryBuffer()._encode(r),user:t.yatta.getUserId()},t.sendIwcIntent("Yatta_push_HB_element",e)}}(this),this.iwcHandler.Yatta_get_HB_element=[c]}return t.prototype.setIwcHandler=function(t){return a=t},t.prototype.sendIwcIntent=function(t,n){var e;return e=null,arguments.length>=2?(t=arguments[0],n=arguments[1],e={action:t,component:"",data:"",dataType:"",flags:["PUBLISH_GLOBAL"],extras:n}):e=arguments[0],this.duiClient.sendIntent(e)},t.prototype.send=function(t){return t.uid.creator===this.HB.getUserId()&&"string"!=typeof t.uid.op_number?this.sendIwcIntent("Yatta_new_operation",t):void 0},t.prototype.receive=function(t){return t.uid.creator!==this.HB.getUserId()?this.engine.applyOp(t):void 0},t}(),i=function(){var n;return n=Math.floor(1e6*Math.random()),t(e,n)},void setTimeout(i,5e3)},n.exports=e,"undefined"!=typeof window&&null!==window&&(null==window.Y&&(window.Y={}),window.Y.createIwcConnector=e)},{}]},{},[1]);
|
||||
!function t(n,e,r){function i(u,a){if(!e[u]){if(!n[u]){var s="function"==typeof require&&require;if(!a&&s)return s(u,!0);if(o)return o(u,!0);throw new Error("Cannot find module '"+u+"'")}var c=e[u]={exports:{}};n[u][0].call(c.exports,function(t){var e=n[u][1][t];return i(e?e:t)},c,c.exports,t,n,e,r)}return e[u].exports}for(var o="function"==typeof require&&require,u=0;u<r.length;u++)i(r[u]);return i}({1:[function(t,n){var e;e=function(t,n){var e,r,i,o,u,a;return a=null,null!=n&&(a=n.iwcHandler),o={},r=new DUIClient,r.connect(function(t){var n;return null!=(n=o[t.action])&&n.map(function(n){return setTimeout(function(){return n(t)},0)}),null!=a?a(t):void 0}),r.initOK(),u=null,e=function(){function t(t,n,e,i){var a,s,c,l;this.engine=t,this.HB=n,this.execution_listener=e,this.yatta=i,this.duiClient=r,this.iwcHandler=o,l=function(t){return function(n){return 0!==Object.getOwnPropertyNames(t.initialized).length?t.send(n):void 0}}(this),this.execution_listener.push(l),this.initialized={},a=function(t){return function(e){var r;return n=e.extras.HB,r=e.extras.user,t.engine.applyOpsCheckDouble(n),t.initialized[r]=!0}}(this),o.Yatta_push_HB_element=[a],this.sendIwcIntent("Yatta_get_HB_element",this.HB.getOperationCounter()),s=function(t){return function(n){var e;return e=n.extras,null!=t.initialized[e.uid.creator]?t.receive(e):void 0}}(this),this.iwcHandler.Yatta_new_operation=[s],null!=u&&this.engine.applyOpsCheckDouble(u),c=function(t){return function(n){var e,r;return r=n.extras,console.log(r),e={HB:t.yatta.getHistoryBuffer()._encode(r),user:t.yatta.getUserId()},t.sendIwcIntent("Yatta_push_HB_element",e)}}(this),this.iwcHandler.Yatta_get_HB_element=[c]}return t.prototype.setIwcHandler=function(t){return a=t},t.prototype.sendIwcIntent=function(t,n){var e;return e=null,arguments.length>=2?(t=arguments[0],n=arguments[1],e={action:t,component:"",data:"",dataType:"",flags:["PUBLISH_GLOBAL"],extras:n}):e=arguments[0],this.duiClient.sendIntent(e)},t.prototype.send=function(t){return t.uid.creator===this.HB.getUserId()&&"string"!=typeof t.uid.op_number?this.sendIwcIntent("Yatta_new_operation",t):void 0},t.prototype.receive=function(t){return t.uid.creator!==this.HB.getUserId()?this.engine.applyOp(t):void 0},t}(),i=function(){var n;return n=Math.floor(1e6*Math.random()),t(e,n)},setTimeout(i,5e3),void 0},n.exports=e,"undefined"!=typeof window&&null!==window&&(null==window.Y&&(window.Y={}),window.Y.createIwcConnector=e)},{}]},{},[1]);
|
@ -1 +1 @@
|
||||
!function n(e,t,r){function o(u,s){if(!t[u]){if(!e[u]){var c="function"==typeof require&&require;if(!s&&c)return c(u,!0);if(i)return i(u,!0);throw new Error("Cannot find module '"+u+"'")}var f=t[u]={exports:{}};e[u][0].call(f.exports,function(n){var t=e[u][1][n];return o(t?t:n)},f,f.exports,n,e,t,r)}return t[u].exports}for(var i="function"==typeof require&&require,u=0;u<r.length;u++)o(r[u]);return o}({1:[function(n,e){var t;t=function(){var n,e,t;return t=null,2===arguments.length?(t=new Peer(arguments[0]),e=arguments[1]):(t=new Peer(arguments[0],arguments[1]),e=arguments[2]),n=function(){function n(n,e,r,o){var i;this.engine=n,this.HB=e,this.execution_listener=r,this.yatta=o,this.peer=t,this.connections={},this.peer.on("connection",function(n){return function(e){return n.addConnection(e)}}(this)),i=function(n){return function(e){var t,r,o,i;if(e.uid.creator===n.HB.getUserId()&&"string"!=typeof e.uid.op_number){o=n.connections,i=[];for(r in o)t=o[r],i.push(t.send({op:e}));return i}}}(this),this.execution_listener.push(i)}return n.prototype.connectToPeer=function(n){return null==this.connections[n]&&n!==this.yatta.getUserId()?this.addConnection(t.connect(n)):void 0},n.prototype.getAllConnectionIds=function(){var n,e;e=[];for(n in this.connections)e.push(n);return e},n.prototype.addConnection=function(n){var e,t,r;return this.connections[n.peer]=n,t=!1,e=!1,n.on("data",function(r){return function(o){var i,u,s,c,f;if("empty_message"===o);else{if(null!=o.HB)return t=!0,r.engine.applyOpsCheckDouble(o.HB),n.send({conns:r.getAllConnectionIds()});if(null!=o.op)return r.engine.applyOp(o.op);if(null!=o.conns){for(c=o.conns,f=[],u=0,s=c.length;s>u;u++)i=c[u],f.push(r.connectToPeer(i));return f}if(null==o.state_vector)throw new Error("Can't parse this operation");if(!e)return n.send({HB:r.yatta.getHistoryBuffer()._encode(o.state_vector)}),e=!0}}}(this)),(r=function(e){return function(){return n.send({state_vector:e.HB.getOperationCounter()}),t?void 0:setTimeout(r,100)}}(this))()},n}(),t.on("open",function(t){return e(n,t)})},e.exports=t,"undefined"!=typeof window&&null!==window&&(null==window.Y&&(window.Y={}),window.Y.createPeerJsConnector=t)},{}]},{},[1]);
|
||||
!function n(t,e,r){function o(u,s){if(!e[u]){if(!t[u]){var c="function"==typeof require&&require;if(!s&&c)return c(u,!0);if(i)return i(u,!0);throw new Error("Cannot find module '"+u+"'")}var a=e[u]={exports:{}};t[u][0].call(a.exports,function(n){var e=t[u][1][n];return o(e?e:n)},a,a.exports,n,t,e,r)}return e[u].exports}for(var i="function"==typeof require&&require,u=0;u<r.length;u++)o(r[u]);return o}({1:[function(n,t){var e;e=function(){var n,t,e;return e=null,2===arguments.length?(e=new Peer(arguments[0]),t=arguments[1]):(e=new Peer(arguments[0],arguments[1]),t=arguments[2]),n=function(){function n(n,t,r,o){var i;this.engine=n,this.HB=t,this.execution_listener=r,this.yatta=o,this.peer=e,this.connections={},this.peer.on("connection",function(n){return function(t){return n.addConnection(t)}}(this)),i=function(n){return function(t){var e,r,o,i;if(t.creator===n.HB.getUserId()&&"string"!=typeof t.uid.op_number&&t.uid.sync){o=n.connections,i=[];for(r in o)e=o[r],i.push(e.send({op:t}));return i}}}(this),this.execution_listener.push(i)}return n.prototype.connectToPeer=function(n){return null==this.connections[n]&&n!==this.yatta.getUserId()?this.addConnection(e.connect(n)):void 0},n.prototype.getAllConnectionIds=function(){var n,t;t=[];for(n in this.connections)t.push(n);return t},n.prototype.addConnection=function(n){var t,e,r;return this.connections[n.peer]=n,e=!1,t=!1,n.on("data",function(r){return function(o){var i,u,s,c,a;if("empty_message"===o);else{if(null!=o.HB)return e=!0,r.engine.applyOpsCheckDouble(o.HB,o.state_vector),n.send({conns:r.getAllConnectionIds()});if(null!=o.op)return r.engine.applyOp(o.op);if(null!=o.conns){for(c=o.conns,a=[],u=0,s=c.length;s>u;u++)i=c[u],a.push(r.connectToPeer(i));return a}if(null==o.state_vector)throw new Error("Can't parse this operation");if(!t)return n.send({HB:r.yatta.getHistoryBuffer()._encode(o.state_vector),state_vector:r.yatta.HB.getOperationCounter()}),t=!0}}}(this)),r=function(t){return function(){return n.send({state_vector:t.HB.getOperationCounter()}),e?void 0:setTimeout(r,100)}}(this),r()},n}(),e.on("open",function(e){return t(n,e)})},t.exports=e,"undefined"!=typeof window&&null!==window&&(null==window.Y&&(window.Y={}),window.Y.createPeerJsConnector=e)},{}]},{},[1]);
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -28,7 +28,7 @@
|
||||
send_ = (function(_this) {
|
||||
return function(o) {
|
||||
var conn, conn_id, _ref, _results;
|
||||
if (o.uid.creator === _this.HB.getUserId() && (typeof o.uid.op_number !== "string")) {
|
||||
if (o.creator === _this.HB.getUserId() && (typeof o.uid.op_number !== "string") && o.uid.sync) {
|
||||
_ref = _this.connections;
|
||||
_results = [];
|
||||
for (conn_id in _ref) {
|
||||
@ -71,7 +71,7 @@
|
||||
|
||||
} else if (data.HB != null) {
|
||||
initialized_me = true;
|
||||
_this.engine.applyOpsCheckDouble(data.HB);
|
||||
_this.engine.applyOpsCheckDouble(data.HB, data.state_vector);
|
||||
return conn.send({
|
||||
conns: _this.getAllConnectionIds()
|
||||
});
|
||||
@ -88,7 +88,8 @@
|
||||
} else if (data.state_vector != null) {
|
||||
if (!initialized_him) {
|
||||
conn.send({
|
||||
HB: _this.yatta.getHistoryBuffer()._encode(data.state_vector)
|
||||
HB: _this.yatta.getHistoryBuffer()._encode(data.state_vector),
|
||||
state_vector: _this.yatta.HB.getOperationCounter()
|
||||
});
|
||||
return initialized_him = true;
|
||||
}
|
||||
|
File diff suppressed because one or more lines are too long
@ -38,18 +38,17 @@
|
||||
return this.tryUnprocessed();
|
||||
};
|
||||
|
||||
Engine.prototype.applyOpsCheckDouble = function(ops_json) {
|
||||
var o, _i, _len, _results;
|
||||
_results = [];
|
||||
Engine.prototype.applyOpsCheckDouble = function(ops_json, state_vector) {
|
||||
var o, _i, _len;
|
||||
for (_i = 0, _len = ops_json.length; _i < _len; _i++) {
|
||||
o = ops_json[_i];
|
||||
if (this.HB.getOperation(o.uid) == null) {
|
||||
_results.push(this.applyOp(o));
|
||||
} else {
|
||||
_results.push(void 0);
|
||||
this.applyOp(o);
|
||||
}
|
||||
}
|
||||
return _results;
|
||||
if (state_vector != null) {
|
||||
return this.HB.renewStateVector(state_vector);
|
||||
}
|
||||
};
|
||||
|
||||
Engine.prototype.applyOps = function(ops_json) {
|
||||
@ -83,7 +82,9 @@
|
||||
_ref = this.unprocessed_ops;
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
op = _ref[_i];
|
||||
if (!op.execute()) {
|
||||
if (this.HB.getOperation(op.getUid()) != null) {
|
||||
|
||||
} else if (!op.execute()) {
|
||||
unprocessed.push(op);
|
||||
} else {
|
||||
this.HB.addOperation(op);
|
||||
|
File diff suppressed because one or more lines are too long
@ -93,6 +93,17 @@
|
||||
}
|
||||
};
|
||||
|
||||
HistoryBuffer.prototype.renewOperationCounter = function(state_vector) {
|
||||
var key, value;
|
||||
for (key in state_vector) {
|
||||
value = state_vector[key];
|
||||
if (this.operation_counter[key] < value) {
|
||||
this.operation_counter[key] = value;
|
||||
}
|
||||
}
|
||||
return void 0;
|
||||
};
|
||||
|
||||
HistoryBuffer.prototype._encode = function(state_vector) {
|
||||
var json, o, o_json, o_next, o_number, o_prev, u_name, unknown, user, _ref;
|
||||
if (state_vector == null) {
|
||||
|
File diff suppressed because one or more lines are too long
@ -222,7 +222,9 @@
|
||||
this.deleted_by = [];
|
||||
}
|
||||
if ((this.parent != null) && !this.isDeleted()) {
|
||||
this.parent.callEvent("delete", this, o);
|
||||
if (o != null) {
|
||||
this.parent.callEvent("delete", this, o);
|
||||
}
|
||||
}
|
||||
if (o != null) {
|
||||
this.deleted_by.push(o);
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -174,16 +174,12 @@
|
||||
WordType.prototype.setReplaceManager = function(op) {
|
||||
this.saveOperation('replace_manager', op);
|
||||
this.validateSavedOperations();
|
||||
this.on('insert', (function(_this) {
|
||||
return function(event, ins) {
|
||||
var _ref;
|
||||
return (_ref = _this.replace_manager) != null ? _ref.forwardEvent(_this, 'change', ins) : void 0;
|
||||
};
|
||||
})(this));
|
||||
this.on('insert', function(event, ins) {
|
||||
return op.forwardEvent(this, 'change', ins);
|
||||
});
|
||||
return this.on('delete', (function(_this) {
|
||||
return function(event, ins, del) {
|
||||
var _ref;
|
||||
return (_ref = _this.replace_manager) != null ? _ref.forwardEvent(_this, 'change', del) : void 0;
|
||||
return op.forwardEvent(_this, 'change', del);
|
||||
};
|
||||
})(this));
|
||||
};
|
||||
|
File diff suppressed because one or more lines are too long
@ -1 +1 @@
|
||||
{"version":3,"sources":["Types/XmlTypes.coffee"],"names":[],"mappings":"AAyGwC;AAAA;AAAA","file":"Types/XmlTypes.js","sourceRoot":"/source/","sourcesContent":[""]}
|
||||
{"version":3,"sources":["Types/XmlTypes.coffee"],"names":[],"mappings":"AA4VkB;AAAA;AAAA","file":"Types/XmlTypes.js","sourceRoot":"/source/","sourcesContent":[""]}
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user