forked from snxraven/LinkUp-P2P-Chat
Trying to make multiple rooms support. This is gonna be a bit of a hell lol.
This commit is contained in:
@ -32,10 +32,11 @@ class Client extends EventEmitter {
|
||||
});
|
||||
}
|
||||
|
||||
sendMessage(message) {
|
||||
sendMessage(roomPeers, message) {
|
||||
console.log('Bot name:', this.botName);
|
||||
const timestamp = Date.now(); // Generate timestamp
|
||||
const peers = [...this.swarm.connections];
|
||||
const peers = [...this.swarm.connections].filter(peer => roomPeers.includes(peer.remotePublicKey.toString('hex')));
|
||||
console.log(`Sending message ${message} to peers ${peers}`)
|
||||
const data = JSON.stringify({name: this.botName, message, timestamp}); // Include timestamp
|
||||
for (const peer of peers) peer.write(data);
|
||||
}
|
||||
|
Reference in New Issue
Block a user