fb15a17b by Glitch (hello-express)

:joy_cat::high_heel: Checkpoint

./server.js:13690106/175
1 parent aa69de6c
{"jack\u001bname":{"":{":":"Jack",">":1586991774902}}}
\ No newline at end of file
{"jack\u001bname":{"":{":":"Jack",">":1586991984290}}}
\ No newline at end of file
......
......@@ -13,7 +13,7 @@ const lru = new QuickLRU({maxSize: 1});
server.on('upgrade', async function (request, socket, head) {
var pathname = url.parse(request.url).pathname || '/gun';
console.log('Got WS request',pathname);
var gun = false;
var gun = { gun: false, server: false};
if (pathname){
if (lru.has(pathname)){
// Existing Node
......@@ -23,17 +23,17 @@ server.on('upgrade', async function (request, socket, head) {
// Create Node
console.log('Create id',pathname);
var wserver = new WebSocket.Server({ noServer: true});
gun = new Gun({peers:[], ws: { path: pathname}, web: server });
lru.set(pathname,gun);
gun = new Gun({peers:[], ws: { path: pathname}, web: wserver });
lru.set(pathname,{gun: gun, server: wserver});
}
}
if (gun){
if (gun.server){
// Handle Request
console.log('handle connection...');
console.log('handle connection...', gun);
//ws.emit('connection', socket);
wserver.handleUpgrade(request, socket, head, function (ws) {
gun.server.handleUpgrade(request, socket, head, function (ws) {
console.log('connecting.. ')
ws.emit('connection', socket);
ws.emit('connection', ws);
});
} else {
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!