diff --git a/guide/making-a-pear-desktop-app.md b/guide/making-a-pear-desktop-app.md index abf9fed..2692bd4 100644 --- a/guide/making-a-pear-desktop-app.md +++ b/guide/making-a-pear-desktop-app.md @@ -203,6 +203,7 @@ swarm.on('connection', (peer) => { // name incoming peers after first 6 chars of its public key as hex const name = b4a.toString(peer.remotePublicKey, 'hex').substr(0, 6) peer.on('data', message => onMessageAdded(name, message)) + peer.on('error', e => console.log(`Connection error: ${e}`)) }) // When there's updates to the swarm, update the peers count diff --git a/guide/making-a-pear-terminal-app.md b/guide/making-a-pear-terminal-app.md index 5dacb2f..91a3cc6 100644 --- a/guide/making-a-pear-terminal-app.md +++ b/guide/making-a-pear-terminal-app.md @@ -41,6 +41,7 @@ swarm.on('connection', peer => { const name = b4a.toString(peer.remotePublicKey, 'hex').substr(0, 6) console.log(`[info] New peer joined, ${name}`) peer.on('data', message => appendMessage({ name, message })) + peer.on('error', e => console.log(`Connection error: ${e}`)) }) swarm.on('update', () => { console.log(`[info] Number of connections is now ${swarm.connections.size}`) diff --git a/howto/connect-to-many-peers-by-topic-with-hyperswarm.md b/howto/connect-to-many-peers-by-topic-with-hyperswarm.md index ef189c2..279ae80 100644 --- a/howto/connect-to-many-peers-by-topic-with-hyperswarm.md +++ b/howto/connect-to-many-peers-by-topic-with-hyperswarm.md @@ -37,6 +37,7 @@ swarm.on('connection', conn => { conns.push(conn) conn.once('close', () => conns.splice(conns.indexOf(conn), 1)) conn.on('data', data => console.log(`${name}: ${data}`)) + conn.on('error', e => console.log(`Connection error: ${e}`)) }) // Broadcast stdin to all connections