2a8992a4 by Jabis Sevón

recent changes

1 parent b2c715bd
...@@ -22,8 +22,8 @@ ...@@ -22,8 +22,8 @@
22 return; 22 return;
23 } 23 }
24 to = setTimeout(flush, opt.wait || 1); 24 to = setTimeout(flush, opt.wait || 1);
25 //var id = at['#'] 25 var id = at['#']
26 //ctx.on('in', {"@": id, ok:1}) 26 ctx.on('in', {"@": id, ok:1})
27 }); 27 });
28 ctx.on('get', function(at){ 28 ctx.on('get', function(at){
29 //console.log("get at",at,disk); 29 //console.log("get at",at,disk);
......
...@@ -49,7 +49,8 @@ server.on("upgrade", async function(request, socket, head) { ...@@ -49,7 +49,8 @@ server.on("upgrade", async function(request, socket, head) {
49 49
50 var gun = { gun: false, server: false }; 50 var gun = { gun: false, server: false };
51 if (pathname) { 51 if (pathname) {
52 let roomname = pathname.split("").slice(1).join(""); 52 let roomname = pathname.split("").slice(1).join("");
53 console.log("roomname",roomname);
53 if (lru.has(pathname)) { 54 if (lru.has(pathname)) {
54 // Existing Node 55 // Existing Node
55 if (debug) console.log("Recycle id", pathname); 56 if (debug) console.log("Recycle id", pathname);
...@@ -86,30 +87,29 @@ server.on("upgrade", async function(request, socket, head) { ...@@ -86,30 +87,29 @@ server.on("upgrade", async function(request, socket, head) {
86 let obj = {roomname:roomname,creator:creator,socket:{}}; 87 let obj = {roomname:roomname,creator:creator,socket:{}};
87 if(sig) { 88 if(sig) {
88 let user = g.user(); 89 let user = g.user();
89 user.create(roomname,sig,async function(ack){ 90 user.create(roomname,sig,async function(dack){
90 console.log("We've got create ack",ack); 91 console.log("We've got create ack",dack,roomname,sig);
91 if(ack.err){ console.log("error in user.create",ack.err); } 92 if(dack.err){ console.log("error in user.create",dack.err); }
92 let auth = await new Promise ((res,rej)=>{ 93 user.auth(roomname,sig,function(auth){
93 return user.auth(roomname,sig,res); 94
95 if(auth.err){ console.log('error in auth',auth.err); }
96 console.log("auth",auth,roomname,sig);
97 Object.assign(obj,{
98 pub:dack.pub,
99 passwordProtected:true
100 })
101 let roomnode = user.get(roomname).put(obj);
102 let putnode = g.get('rtcmeeting').get(roomname);
103 let rack= putnode.put(roomnode);
104 console.log("room created");
105 rack.once(Gun.log);
94 }); 106 });
95 if(auth.err){ console.log('error in auth',auth.err); }
96 console.log("auth",auth);
97 Object.assign(obj,{
98 pub:ack.pub,
99 passwordProtected:true
100 })
101 let roomnode = user.get(roomname).put(obj);
102 let putnode = g.get('rtcmeeting').get(roomname).put(roomnode);
103 let rack= await putnode.then();
104 console.log("room created",rack);
105 }); 107 });
106 } else { 108 } else {
107 ;(async ()=>{ 109 Object.assign(obj,{passwordProtected:false});
108 Object.assign(obj,{passwordProtected:false}); 110 let roomnode = g.get("rtcmeeting").get(roomname).put(obj,function(rack){
109 let roomnode = g.get("rtcmeeting").get(roomname).put(obj);
110 let rack = await roomnode.then();
111 console.log("room created",rack); 111 console.log("room created",rack);
112 })() 112 });
113 } 113 }
114 } 114 }
115 } 115 }
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!