Fixed app.js not sending user ID itself and only peers it knows #5
6
app.js
6
app.js
@ -296,13 +296,17 @@ function sendMessage(e) {
|
||||
|
||||
onMessageAdded(config.userName, message, config.userAvatar);
|
||||
|
||||
let peersPublicKeys = [];
|
||||
peersPublicKeys.push([...swarm.connections].map(peer => peer.remotePublicKey.toString('hex')));
|
||||
peersPublicKeys.push(swarm.keyPair.publicKey.toString('hex'));
|
||||
|
||||
const messageObj = JSON.stringify({
|
||||
type: 'message',
|
||||
name: config.userName,
|
||||
message,
|
||||
avatar: config.userAvatar,
|
||||
topic: b4a.toString(currentRoom.topic, 'hex'),
|
||||
peers: [...swarm.connections].map(peer => peer.remotePublicKey.toString('hex')).push(swarm.keyPair.publicKey.toString('hex')),
|
||||
peers: peersPublicKeys,
|
||||
timestamp: Date.now(),
|
||||
readableTimestamp: new Date().toLocaleString(), // Added human-readable timestamp
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user