added new y-test connector

This commit is contained in:
DadaMonad
2015-02-05 14:15:20 +00:00
parent 3eb933400a
commit e5f16812b3
19 changed files with 281 additions and 213 deletions

11
build/README.md Normal file
View File

@@ -0,0 +1,11 @@
# Directories
### build/browser
You find the browserified (not minified) version of yjs here. This is nice for debugging, since it also includes sourcemaps. For production, however, you should use the version that you find in the main directory.
### build/node
Yjs for nodejs is located here. You can only use the submodules, or require 'y' in your node project. Also works with browserify.
### build/test
Start build/test/index.html' in your browser, to perform testing Yjs.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -58,7 +58,6 @@ adaptConnector = function(connector, engine, HB, execution_listener) {
connector.getStateVector = getStateVector;
connector.getHB = getHB;
connector.applyHB = applyHB;
connector.receive_handlers = [];
return connector.receive_handlers.push(function(sender, op) {
if (op.uid.creator !== HB.getUserId()) {
return engine.applyOp(op);

View File

@@ -19,12 +19,20 @@ module.exports = {
req("syncMode", ["syncAll", "master-slave"]);
req("role", ["master", "slave"]);
req("user_id");
this.on_user_id_set(this.user_id);
if (typeof this.on_user_id_set === "function") {
this.on_user_id_set(this.user_id);
}
if (options.perform_send_again != null) {
this.perform_send_again = options.perform_send_again;
} else {
this.perform_send_again = true;
}
if (this.role === "master") {
this.syncMode = "syncAll";
}
this.is_synced = false;
this.connections = {};
this.receive_handlers = [];
this.is_bound_to_y = false;
this.connections = {};
this.current_sync_target = null;
@@ -59,12 +67,14 @@ module.exports = {
return this.findNewSyncTarget();
},
userJoined: function(user, role) {
var _base;
if (role == null) {
throw new Error("Internal: You must specify the role of the joined user! E.g. userJoined('uid:3939','slave')");
}
this.connections[user] = {
is_synced: false
};
if ((_base = this.connections)[user] == null) {
_base[user] = {};
}
this.connections[user].is_synced = false;
if ((!this.is_synced) || this.syncMode === "syncAll") {
if (this.syncMode === "syncAll") {
return this.performSync(user);
@@ -164,12 +174,14 @@ module.exports = {
var f, _i, _len, _ref;
if (!this.is_synced) {
this.is_synced = true;
_ref = this.compute_when_synced;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
f = _ref[_i];
f();
if (this.compute_when_synced != null) {
_ref = this.compute_when_synced;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
f = _ref[_i];
f();
}
delete this.compute_when_synced;
}
delete this.compute_when_synced;
return null;
}
},
@@ -219,7 +231,7 @@ module.exports = {
sync_step: "applyHB",
data: _hb
});
if (res.send_again != null) {
if ((res.send_again != null) && this.perform_send_again) {
send_again = (function(_this) {
return function(sv) {
return function() {

View File

@@ -186,7 +186,7 @@ module.exports = function(HB) {
ReplaceManager.prototype.callEventDecorator = function(events) {
var event, name, prop, _i, _len, _ref;
if (!(this.isDeleted() || this.getLastOperation().isDeleted())) {
if (!this.isDeleted()) {
for (_i = 0, _len = events.length; _i < _len; _i++) {
event = events[_i];
_ref = this.event_properties;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,7 +1,7 @@
<html>
<head>
<meta charset="utf-8">
<title>Test Yatta!</title>
<title>Test Yjs!</title>
<link rel="stylesheet" href="../../node_modules/mocha/mocha.css" />
</head>
<body>
@@ -13,9 +13,9 @@
mocha.ui('bdd');
mocha.reporter('html');
</script>
<script src="TextYatta_test.js"></script>
<script src="JsonYatta_test.js"></script>
<!--script src="XmlYatta_test_browser.js"></script-->
<script src="Text_test.js"></script>
<script src="Json_test.js"></script>
<!--script src="Xml_test_browser.js"></script-->
<script>
//mocha.checkLeaks();
//mocha.run();