Debug
This commit is contained in:
parent
6a7eb78d34
commit
3c803c811e
9
app.js
9
app.js
@ -38,6 +38,7 @@ function getRandomPort() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function initialize() {
|
async function initialize() {
|
||||||
|
try {
|
||||||
swarm = new Hyperswarm();
|
swarm = new Hyperswarm();
|
||||||
|
|
||||||
servePort = getRandomPort();
|
servePort = getRandomPort();
|
||||||
@ -193,6 +194,9 @@ async function initialize() {
|
|||||||
document.addEventListener("DOMContentLoaded", (event) => {
|
document.addEventListener("DOMContentLoaded", (event) => {
|
||||||
hljs.highlightAll();
|
hljs.highlightAll();
|
||||||
});
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error during initialization:', error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setupTalkButton() {
|
function setupTalkButton() {
|
||||||
@ -321,6 +325,7 @@ async function joinChatRoom(e) {
|
|||||||
async function joinSwarm(topicBuffer) {
|
async function joinSwarm(topicBuffer) {
|
||||||
const topic = b4a.toString(topicBuffer, 'hex');
|
const topic = b4a.toString(topicBuffer, 'hex');
|
||||||
if (!activeRooms.some(room => room.topic === topic)) {
|
if (!activeRooms.some(room => room.topic === topic)) {
|
||||||
|
try {
|
||||||
const discovery = swarm.join(topicBuffer, { client: true, server: true });
|
const discovery = swarm.join(topicBuffer, { client: true, server: true });
|
||||||
await discovery.flushed();
|
await discovery.flushed();
|
||||||
|
|
||||||
@ -329,6 +334,9 @@ async function joinSwarm(topicBuffer) {
|
|||||||
console.log('Joined room:', topic); // Debugging log
|
console.log('Joined room:', topic); // Debugging log
|
||||||
|
|
||||||
renderMessagesForRoom(topic);
|
renderMessagesForRoom(topic);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error joining swarm for topic:', topic, error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -667,6 +675,7 @@ function addAudioMessage(from, audioUrl, avatar, topic) {
|
|||||||
console.log(`Message for topic ${topic} not rendered because current topic is ${currentTopic}`); // Debugging log
|
console.log(`Message for topic ${topic} not rendered because current topic is ${currentTopic}`); // Debugging log
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function truncateHash(hash) {
|
function truncateHash(hash) {
|
||||||
return `${hash.slice(0, 6)}...${hash.slice(-6)}`;
|
return `${hash.slice(0, 6)}...${hash.slice(-6)}`;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user