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