added option for servers that want to propagate applied operations (aka the websockets connector)
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user