Deploy 0.8.4

This commit is contained in:
Kevin Jahns 2016-01-15 17:58:01 +01:00
parent 3b8e148d8f
commit a4fc6e9976
5 changed files with 40 additions and 27 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "yjs", "name": "yjs",
"version": "0.8.4", "version": "0.8.5",
"homepage": "y-js.org", "homepage": "y-js.org",
"authors": [ "authors": [
"Kevin Jahns <kevin.jahns@rwth-aachen.de>" "Kevin Jahns <kevin.jahns@rwth-aachen.de>"

55
y.es6
View File

@ -51,6 +51,7 @@ module.exports = function (Y/* :any */) {
this.debug = opts.debug === true this.debug = opts.debug === true
this.broadcastedHB = false this.broadcastedHB = false
this.syncStep2 = Promise.resolve() this.syncStep2 = Promise.resolve()
this.broadcastOpBuffer = []
} }
reconnect () { reconnect () {
} }
@ -167,6 +168,31 @@ module.exports = function (Y/* :any */) {
console.log(`send ${this.userId} -> ${uid}: ${message.type}`, message) // eslint-disable-line console.log(`send ${this.userId} -> ${uid}: ${message.type}`, message) // eslint-disable-line
} }
} }
/*
Buffer operations, and broadcast them when ready.
*/
broadcastOps (ops) {
var self = this
function broadcastOperations () {
if (self.broadcastOpBuffer.length > 0) {
self.broadcast({
type: 'update',
ops: self.broadcastOpBuffer
})
self.broadcastOpBuffer = []
}
}
if (this.broadcastOpBuffer.length === 0) {
this.broadcastOpBuffer = ops
if (this.y.db.transactionInProgress) {
this.y.db.whenTransactionsFinished().then(broadcastOperations)
} else {
setTimeout(broadcastOperations, 0)
}
} else {
this.broadcastOpBuffer = this.broadcastOpBuffer.concat(ops)
}
}
/* /*
You received a raw message, and you know that it is intended for Yjs. Then call this function. You received a raw message, and you know that it is intended for Yjs. Then call this function.
*/ */
@ -227,15 +253,14 @@ module.exports = function (Y/* :any */) {
db.requestTransaction(function * () { db.requestTransaction(function * () {
var ops = yield* this.getOperations(m.stateSet) var ops = yield* this.getOperations(m.stateSet)
if (ops.length > 0) { if (ops.length > 0) {
var update /* :MessageUpdate */ = { if (!broadcastHB) { // TODO: consider to broadcast here..
conn.send(sender, {
type: 'update', type: 'update',
ops: ops ops: ops
} })
if (!broadcastHB) { // TODO: consider to broadcast here..
conn.send(sender, update)
} else { } else {
// broadcast only once! // broadcast only once!
conn.broadcast(update) conn.broadcastOps(ops)
} }
} }
defer.resolve() defer.resolve()
@ -257,10 +282,7 @@ module.exports = function (Y/* :any */) {
return o.struct === 'Delete' return o.struct === 'Delete'
}) })
if (delops.length > 0) { if (delops.length > 0) {
this.broadcast({ this.broadcastOps(delops)
type: 'update',
ops: delops
})
} }
} }
this.y.db.apply(message.ops) this.y.db.apply(message.ops)
@ -1406,10 +1428,7 @@ module.exports = function (Y/* :any */) {
} }
if (!this.store.y.connector.isDisconnected() && send.length > 0) { // TODO: && !this.store.forwardAppliedOperations (but then i don't send delete ops) if (!this.store.y.connector.isDisconnected() && send.length > 0) { // TODO: && !this.store.forwardAppliedOperations (but then i don't send delete ops)
// is connected, and this is not going to be send in addOperation // is connected, and this is not going to be send in addOperation
this.store.y.connector.broadcast({ this.store.y.connector.broadcastOps(send)
type: 'update',
ops: send
})
} }
} }
@ -1805,10 +1824,7 @@ module.exports = function (Y/* :any */) {
var ops = deletions.map(function (d) { var ops = deletions.map(function (d) {
return {struct: 'Delete', target: [d[0], d[1]]} return {struct: 'Delete', target: [d[0], d[1]]}
}) })
this.store.y.connector.broadcast({ this.store.y.connector.broadcastOps(ops)
type: 'update',
ops: ops
})
} }
} }
* isGarbageCollected (id) { * isGarbageCollected (id) {
@ -1846,10 +1862,7 @@ module.exports = function (Y/* :any */) {
yield* this.os.put(op) yield* this.os.put(op)
if (!this.store.y.connector.isDisconnected() && this.store.forwardAppliedOperations && op.id[0] !== '_') { if (!this.store.y.connector.isDisconnected() && this.store.forwardAppliedOperations && op.id[0] !== '_') {
// is connected, and this is not going to be send in addOperation // is connected, and this is not going to be send in addOperation
this.store.y.connector.broadcast({ this.store.y.connector.broadcastOps([op])
type: 'update',
ops: [op]
})
} }
} }
* getOperation (id/* :any */)/* :Transaction<any> */ { * getOperation (id/* :any */)/* :Transaction<any> */ {

File diff suppressed because one or more lines are too long

4
y.js

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long