webrtc connector working
This commit is contained in:
parent
6b153896dd
commit
9b3fe2f197
21
gulpfile.js
21
gulpfile.js
@ -70,23 +70,34 @@ var options = minimist(process.argv.slice(2), {
|
||||
});
|
||||
|
||||
var files = {
|
||||
y: polyfills.concat(["src/y.js", "src/**/*.js", "!src/**/*.spec.js"]),
|
||||
y: polyfills.concat(["src/y.js", "src/Connector.js", "src/OperationStore.js", "src/Struct.js", "src/**/*.js", "!src/**/*.spec.js"]),
|
||||
lint: ["src/**/*.js", "gulpfile.js"],
|
||||
test: polyfills.concat([options.testfiles]),
|
||||
build_test: ["build_test/y.js"]
|
||||
};
|
||||
|
||||
gulp.task("build", function () {
|
||||
return gulp.src(files.y)
|
||||
/*return gulp.src(files.y)
|
||||
.pipe(sourcemaps.init())
|
||||
.pipe(concat(options.name))
|
||||
.pipe(babel({
|
||||
loose: "all",
|
||||
modules: options.export
|
||||
modules: options.export,
|
||||
// blacklist: "regenerator" // you can't uglify when regenerator is blacklisted!
|
||||
}))
|
||||
.pipe(uglify())
|
||||
.pipe(sourcemaps.write("."))
|
||||
.pipe(gulp.dest("."));
|
||||
.pipe(gulp.dest("."));*/
|
||||
return gulp.src(files.y)
|
||||
.pipe(sourcemaps.init())
|
||||
.pipe(concat(options.name))
|
||||
.pipe(babel({
|
||||
loose: "all",
|
||||
modules: "ignore",
|
||||
blacklist: ["regenerator"]
|
||||
}))
|
||||
.pipe(sourcemaps.write())
|
||||
.pipe(gulp.dest("."));
|
||||
});
|
||||
|
||||
gulp.task("lint", function(){
|
||||
@ -131,7 +142,7 @@ gulp.task("develop", ["build_jasmine_browser", "build"], function(){
|
||||
|
||||
gulp.watch(files.test, ["build_jasmine_browser"]);
|
||||
//gulp.watch(files.test, ["test"]);
|
||||
//gulp.watch(files.test, ["build"]);
|
||||
gulp.watch(files.test, ["build"]);
|
||||
|
||||
return gulp.src("build/jasmine_browser.js")
|
||||
.pipe(watch("build/jasmine_browser.js"))
|
||||
|
@ -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];
|
||||
|
Loading…
x
Reference in New Issue
Block a user