forked from snxraven/LinkUp-P2P-Chat
Revert "Bug Fix: Allowing clients to have different ServePorts per client and storages per client"
This reverts commit 5f8817a2f2
.
This commit is contained in:
parent
5f8817a2f2
commit
5931d68a29
15
app.js
15
app.js
@ -8,8 +8,7 @@ import Hyperdrive from 'hyperdrive';
|
|||||||
import Corestore from 'corestore';
|
import Corestore from 'corestore';
|
||||||
import { EventEmitter } from 'events';
|
import { EventEmitter } from 'events';
|
||||||
|
|
||||||
const storagePath = `./storage_${Date.now()}_${Math.random().toString(36).substring(2, 15)}`;
|
const store = new Corestore('./storage');
|
||||||
const store = new Corestore(storagePath);
|
|
||||||
const drive = new Hyperdrive(store);
|
const drive = new Hyperdrive(store);
|
||||||
|
|
||||||
await drive.ready();
|
await drive.ready();
|
||||||
@ -22,18 +21,10 @@ let peerCount = 0;
|
|||||||
let currentRoom = null;
|
let currentRoom = null;
|
||||||
const eventEmitter = new EventEmitter();
|
const eventEmitter = new EventEmitter();
|
||||||
|
|
||||||
// Define servePort at the top level
|
|
||||||
let servePort;
|
|
||||||
|
|
||||||
// Function to get a random port between 1337 and 2223
|
|
||||||
function getRandomPort() {
|
|
||||||
return Math.floor(Math.random() * (2223 - 1337 + 1)) + 1337;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function initialize() {
|
async function initialize() {
|
||||||
swarm = new Hyperswarm();
|
swarm = new Hyperswarm();
|
||||||
|
|
||||||
servePort = getRandomPort();
|
const servePort = 1337;
|
||||||
const serve = new ServeDrive({ port: servePort, get: ({ key, filename, version }) => drive });
|
const serve = new ServeDrive({ port: servePort, get: ({ key, filename, version }) => drive });
|
||||||
await serve.ready();
|
await serve.ready();
|
||||||
console.log('Listening on http://localhost:' + serve.address().port);
|
console.log('Listening on http://localhost:' + serve.address().port);
|
||||||
@ -138,7 +129,7 @@ function registerUser(e) {
|
|||||||
reader.onload = async (event) => {
|
reader.onload = async (event) => {
|
||||||
const buffer = new Uint8Array(event.target.result);
|
const buffer = new Uint8Array(event.target.result);
|
||||||
await drive.put(`/icons/${regUsername}.png`, buffer);
|
await drive.put(`/icons/${regUsername}.png`, buffer);
|
||||||
userAvatar = `http://localhost:${servePort}/icons/${regUsername}.png`; // Set the correct URL
|
userAvatar = `http://localhost:1337/icons/${regUsername}.png`; // Set the correct URL
|
||||||
registeredUsers[regUsername] = userAvatar;
|
registeredUsers[regUsername] = userAvatar;
|
||||||
localStorage.setItem('registeredUsers', JSON.stringify(registeredUsers));
|
localStorage.setItem('registeredUsers', JSON.stringify(registeredUsers));
|
||||||
continueRegistration(regUsername);
|
continueRegistration(regUsername);
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 18 KiB |
Binary file not shown.
Binary file not shown.
@ -1 +0,0 @@
|
|||||||
Ÿ(â°f¿éh»8ÓFOv//oOa«[Ô™–|U9{Á
|
|
Binary file not shown.
Binary file not shown.
@ -1 +0,0 @@
|
|||||||
<EFBFBD>4<EFBFBD>ھ<EFBFBD><EFBFBD>P,8<><38>UW<55>Y<EFBFBD><59><EFBFBD><EFBFBD><EFBFBD>X<EFBFBD>ܲkC<><EFBFBD>
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 2.3 KiB |
Binary file not shown.
@ -1 +0,0 @@
|
|||||||
賴B-HGnゥxfムモ=&遂3ぇZム
セ貢Cシァ"カ
|
|
Binary file not shown.
Before Width: | Height: | Size: 110 KiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1 +0,0 @@
|
|||||||
њcїSµd$и’„тЩх‚ЧvОґДќЈГ…ЉJЌЊ1Рjщ
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 110 KiB |
Binary file not shown.
@ -1 +0,0 @@
|
|||||||
<EFBFBD><EFBFBD>`N<><1F><>3<EFBFBD>t<EFBFBD><74>s<EFBFBD>H|MS"<22>k<EFBFBD><6B><10><>]
|
|
Loading…
Reference in New Issue
Block a user