ot.js
ot.js copied to clipboard
Please add some proper documentation or at least an example
The documentation on this is really, really bad! There's no explanation on how to start a server. No explanation on how this would work with CodeMirror.
All you really know is that it is used with socket.io. That you need to handle operations on the server by sending them to all the clients. And that's it.
How do you start the server? How do you connect to the server? How do you handle operations on the server? How would you implement CodeMirror?
I assume the server is started with
myServer = new ot.Server("my document's text content");
and needs to get a broadcast callback function, which is responsible for delivering the operations resulting from user input to all clients (and has to be implemented by you):
myServer.broadcast = (operation) => { handle the broadcast of "operation" to the clients };
That incoming changes should go into...
myServer.receiveOperation(clients_current_revision, operation_from_client);
...is just a wild guess, since there is no information about that in the docs.
And that's where it starts to throw errors, since in line 30 of server.js, apply() is called on an operation, which of course doesn't have an apply function....
Any ideas? Anybody got that library working? Thanks!
@bjorno43 @stefanholzapfel Here is my demo using ot.js: https://github.com/YingshanDeng/ot.js-demo