Compare commits

..

3 Commits

Author SHA1 Message Date
Kevin Jahns
fd24c85437 v13.0.0-19 -- distribution files 2017-09-26 21:53:13 +02:00
Kevin Jahns
be537c9f8c 13.0.0-19 2017-09-26 21:53:01 +02:00
Kevin Jahns
4028eee39d implemented chunked broadcast of updates 2017-09-26 21:52:07 +02:00
9 changed files with 23619 additions and 14 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "yjs",
"version": "13.0.0-18",
"version": "13.0.0-19",
"description": "A framework for real-time p2p shared editing on any data",
"main": "./y.node.js",
"browser": "./y.js",

View File

@@ -42,6 +42,11 @@ export default function extendConnector (Y/* :any */) {
if (opts.generateUserId !== false) {
this.setUserId(Y.utils.generateUserId())
}
if (opts.maxBufferLength == null) {
this.maxBufferLength = -1
} else {
this.maxBufferLength = opts.maxBufferLength
}
}
reconnect () {
@@ -197,14 +202,19 @@ export default function extendConnector (Y/* :any */) {
encoder.writeVarString(self.opts.room)
encoder.writeVarString('update')
let ops = self.broadcastOpBuffer
self.broadcastOpBuffer = []
let length = ops.length
encoder.writeUint32(length)
for (var i = 0; i < length; i++) {
let encoderPosLen = encoder.pos
encoder.writeUint32(0)
for (var i = 0; i < length && (self.maxBufferLength < 0 || encoder.length < self.maxBufferLength); i++) {
let op = ops[i]
Y.Struct[op.struct].binaryEncode(encoder, op)
}
encoder.setUint32(encoderPosLen, i)
self.broadcastOpBuffer = ops.slice(i)
self.broadcast(encoder.createBuffer())
if (i !== length) {
setTimeout(broadcastOperations, 100)
}
}
}
if (this.broadcastOpBuffer.length === 0) {

View File

@@ -8,6 +8,10 @@ export class BinaryEncoder {
this.data = []
}
get length () {
return this.data.length
}
get pos () {
return this.data.length
}

8
y.js

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 @@
/**
* yjs - A framework for real-time p2p shared editing on any data
* @version v13.0.0-18
* @version v13.0.0-19
* @license MIT
*/
@@ -292,6 +292,10 @@ class BinaryEncoder {
this.data = [];
}
get length () {
return this.data.length
}
get pos () {
return this.data.length
}
@@ -666,6 +670,11 @@ function extendConnector (Y/* :any */) {
if (opts.generateUserId !== false) {
this.setUserId(Y.utils.generateUserId());
}
if (opts.maxBufferLength == null) {
this.maxBufferLength = -1;
} else {
this.maxBufferLength = opts.maxBufferLength;
}
}
reconnect () {
@@ -821,14 +830,19 @@ function extendConnector (Y/* :any */) {
encoder.writeVarString(self.opts.room);
encoder.writeVarString('update');
let ops = self.broadcastOpBuffer;
self.broadcastOpBuffer = [];
let length = ops.length;
encoder.writeUint32(length);
for (var i = 0; i < length; i++) {
let encoderPosLen = encoder.pos;
encoder.writeUint32(0);
for (var i = 0; i < length && (self.maxBufferLength < 0 || encoder.length < self.maxBufferLength); i++) {
let op = ops[i];
Y.Struct[op.struct].binaryEncode(encoder, op);
}
encoder.setUint32(encoderPosLen, i);
self.broadcastOpBuffer = ops.slice(i);
self.broadcast(encoder.createBuffer());
if (i !== length) {
setTimeout(broadcastOperations, 100);
}
}
}
if (this.broadcastOpBuffer.length === 0) {

File diff suppressed because one or more lines are too long

23576
y.test.js Normal file

File diff suppressed because one or more lines are too long

1
y.test.js.map Normal file

File diff suppressed because one or more lines are too long