Fixed app.js not sending user ID itself and only peers it knows #5

Merged
snxraven merged 26 commits from MiTask/LinkUp-P2P-Chat:main into main 2024-06-10 11:26:59 -04:00
Showing only changes of commit 704f6ca0dc - Show all commits

4
app.js
View File

@ -296,13 +296,15 @@ function sendMessage(e) {
onMessageAdded(config.userName, message, config.userAvatar); onMessageAdded(config.userName, message, config.userAvatar);
console.log(swarm.keyPair);
console.log("swarm:", swarm);
const messageObj = JSON.stringify({ const messageObj = JSON.stringify({
type: 'message', type: 'message',
name: config.userName, name: config.userName,
message, message,
avatar: config.userAvatar, avatar: config.userAvatar,
topic: b4a.toString(currentRoom.topic, 'hex'), topic: b4a.toString(currentRoom.topic, 'hex'),
peers: [...swarm.connections].map(peer => peer.remotePublicKey.toString('hex')).push(swarm.publicKey.toString('hex')), peers: [...swarm.connections].map(peer => peer.remotePublicKey.toString('hex')),
timestamp: Date.now(), timestamp: Date.now(),
readableTimestamp: new Date().toLocaleString(), // Added human-readable timestamp readableTimestamp: new Date().toLocaleString(), // Added human-readable timestamp
}); });