I actually didnt fix the issue with array of arrays. Now it should be fine
This commit is contained in:
parent
ecfc62ff2c
commit
d993090f8b
3
app.js
3
app.js
@ -297,7 +297,8 @@ function sendMessage(e) {
|
|||||||
onMessageAdded(config.userName, message, config.userAvatar);
|
onMessageAdded(config.userName, message, config.userAvatar);
|
||||||
|
|
||||||
let peersPublicKeys = [];
|
let peersPublicKeys = [];
|
||||||
peersPublicKeys.push([...swarm.connections].map(peer => peer.remotePublicKey.toString('hex')).flat(1));
|
peersPublicKeys.push([...swarm.connections].map(peer => peer.remotePublicKey.toString('hex')));
|
||||||
|
peersPublicKeys = peersPublicKeys.flat(1);
|
||||||
peersPublicKeys.push(swarm.keyPair.publicKey.toString('hex'));
|
peersPublicKeys.push(swarm.keyPair.publicKey.toString('hex'));
|
||||||
|
|
||||||
const messageObj = JSON.stringify({
|
const messageObj = JSON.stringify({
|
||||||
|
@ -22,7 +22,7 @@ class Client extends EventEmitter {
|
|||||||
this.swarm.on('update', () => {
|
this.swarm.on('update', () => {
|
||||||
console.log(`Peers count: ${this.swarm.connections.size}`);
|
console.log(`Peers count: ${this.swarm.connections.size}`);
|
||||||
if(this.swarm.connections.size > 0) {
|
if(this.swarm.connections.size > 0) {
|
||||||
let peers = [...this.swarm.peers].filter(peer => peer && peer.publicKey && peer.publicKey.toString('hex').startsWith("51be150"))
|
let peers = [...this.swarm.peers].filter(peer => peer && peer.publicKey && peer.publicKey.toString('hex').startsWith("a4eb7f"))
|
||||||
if(peers.length > 0) {
|
if(peers.length > 0) {
|
||||||
console.log(peers[0])
|
console.log(peers[0])
|
||||||
console.log([peers[0].topics]);
|
console.log([peers[0].topics]);
|
||||||
|
Loading…
Reference in New Issue
Block a user