webrtc connector working
This commit is contained in:
@@ -113,6 +113,9 @@ class AbstractConnector { //eslint-disable-line no-unused-vars
|
||||
}
|
||||
// You received a raw message, and you know that it is intended for to Yjs. Then call this function.
|
||||
receiveMessage (sender, m){
|
||||
if (sender === this.userId) {
|
||||
return;
|
||||
}
|
||||
if (this.debug) {
|
||||
console.log(`${sender} -> ${this.userId}: ${JSON.stringify(m)}`); //eslint-disable-line
|
||||
}
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
|
||||
class WebRTC extends AbstractConnector {
|
||||
constructor (options) {
|
||||
constructor (y, options) {
|
||||
if(options === undefined){
|
||||
throw new Error("Options must not be undefined!");
|
||||
}
|
||||
super({
|
||||
role: "slave"
|
||||
});
|
||||
if(options.room == null) {
|
||||
throw new Error("You must define a room name!");
|
||||
}
|
||||
options.role = "slave";
|
||||
super(y, options);
|
||||
|
||||
var room = options.room;
|
||||
|
||||
@@ -25,12 +27,13 @@ class WebRTC extends AbstractConnector {
|
||||
|
||||
swr.once("joinedRoom", function(){
|
||||
self.setUserId(userId);
|
||||
/*
|
||||
var i;
|
||||
// notify the connector class about all the users that already
|
||||
// joined the session
|
||||
for(i in self.swr.webrtc.peers){
|
||||
self.userJoined(self.swr.webrtc.peers[i].id, "master");
|
||||
}
|
||||
}*/
|
||||
swr.on("channelMessage", function(peer, room_, message){
|
||||
// The client received a message
|
||||
// Check if the connector is already initialized,
|
||||
|
||||
@@ -93,7 +93,7 @@ class AbstractOperationStore { //eslint-disable-line no-unused-vars
|
||||
apply (ops) {
|
||||
for (var key in ops) {
|
||||
var o = ops[key];
|
||||
var required = Y.Struct[o.struct].requiredOps(o);
|
||||
var required = Struct[o.struct].requiredOps(o);
|
||||
this.whenOperationsExist(required, o);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,6 +97,9 @@ Y.Memory = (function(){ //eslint-disable-line no-unused-vars
|
||||
}
|
||||
*makeOperationReady (ss, op) {
|
||||
// instead of ss, you could use currSS (a ss that increments when you add an operation)
|
||||
if (op.right == null) {
|
||||
return op;
|
||||
}
|
||||
var clock;
|
||||
var o = op;
|
||||
while (o.right != null){
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
this._model = _model;
|
||||
// Array of all the operation id's
|
||||
this.idArray = idArray;
|
||||
// Array of all the values
|
||||
this.valArray = valArray;
|
||||
this.eventHandler = new EventHandler( ops =>{
|
||||
for (var i in ops) {
|
||||
|
||||
@@ -104,7 +104,11 @@ class EventHandler {
|
||||
// if property does not exist, return null
|
||||
// if property is a type, return a promise
|
||||
if (this.opContents[key] == null) {
|
||||
return this.contents[key];
|
||||
if (key == null) {
|
||||
return copyObject(this.contents);
|
||||
} else {
|
||||
return this.contents[key];
|
||||
}
|
||||
} else {
|
||||
let def = Promise.defer();
|
||||
var oid = this.opContents[key];
|
||||
|
||||
Reference in New Issue
Block a user