added option for servers that want to propagate applied operations (aka the websockets connector)

This commit is contained in:
Kevin Jahns
2015-11-15 02:04:06 +01:00
parent ae12b087e7
commit 58a612eaa1
3 changed files with 32 additions and 1 deletions

View File

@@ -20,6 +20,7 @@ module.exports = function (Y) {
} else {
throw new Error("Role must be either 'master' or 'slave'!")
}
this.y.db.forwardAppliedOperations = opts.forwardAppliedOperations || false
this.role = opts.role
this.connections = {}
this.isSynced = false
@@ -221,6 +222,17 @@ module.exports = function (Y) {
this.send(client, m)
}
}
if (this.y.db.forwardAppliedOperations) {
var delops = m.ops.filter(function (o) {
return o.struct === 'Delete'
})
if (delops.length > 0) {
this.broadcast({
type: 'update',
ops: delops
})
}
}
this.y.db.apply(m.ops)
}
}