added option *generateUserId* in abstract connector
This commit is contained in:
parent
922637930f
commit
f996ac83d2
@ -151,6 +151,7 @@ Report _any_ issues to the [Github issue page](https://github.com/y-js/yjs/issue
|
||||
* All our connectors implement a `room` property. Clients that specify the same room share the same data.
|
||||
* All of our connectors specify an `url` property that defines the connection endpoint of the used connector.
|
||||
* All of our connectors also have a default connection endpoint that you can use for development.
|
||||
* Set `options.connector.generateUserId = true` in order to genenerate a userid, instead of receiving one from the server. This way the `Y(..)` is immediately going to be resolved, without waiting for any confirmation from the server. Use with caution.
|
||||
* Have a look at the used connector repository to see all available options.
|
||||
* options.sourceDir (browser only)
|
||||
* Path where all y-* modules are stored
|
||||
@ -273,4 +274,3 @@ I created this framework during my bachelor thesis at the chair of computer scie
|
||||
Yjs is licensed under the [MIT License](./LICENSE).
|
||||
|
||||
<yjs@dbis.rwth-aachen.de>
|
||||
|
||||
|
@ -59,6 +59,9 @@ module.exports = function (Y/* :any */) {
|
||||
this.protocolVersion = 11
|
||||
this.authInfo = opts.auth || null
|
||||
this.checkAuth = opts.checkAuth || function () { return Promise.resolve('write') } // default is everyone has write access
|
||||
if (opts.generateUserId === true) {
|
||||
this.setUserId(Y.utils.generateGuid())
|
||||
}
|
||||
}
|
||||
resetAuth (auth) {
|
||||
if (this.authInfo !== auth) {
|
||||
|
@ -752,4 +752,9 @@ module.exports = function (Y /* : any*/) {
|
||||
return SmallLookupBuffer
|
||||
}
|
||||
Y.utils.createSmallLookupBuffer = createSmallLookupBuffer
|
||||
|
||||
// Generates a unique id, for use as a user id.
|
||||
// Thx to @jed for this script https://gist.github.com/jed/982883
|
||||
function generateGuid(a){return a?(a^Math.random()*16>>a/4).toString(16):([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,generateGuid)} // eslint-disable-line
|
||||
Y.utils.generateGuid = generateGuid
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user