Skip to content

Commit

Permalink
fix: use unidirectional streams (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
vasco-santos authored Jun 4, 2020
1 parent bcadfef commit c6ba48d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 0 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ class PubsubBaseProtocol extends EventEmitter {
protocols: [protocol]
}))

peer.attachConnection(stream)
this._processMessages(idB58Str, stream, peer)
}

Expand All @@ -200,7 +199,6 @@ class PubsubBaseProtocol extends EventEmitter {
try {
const { stream } = await conn.newStream(this.multicodecs)
peer.attachConnection(stream)
this._processMessages(idB58Str, stream, peer)
} catch (err) {
this.log.err(err)
}
Expand Down
2 changes: 2 additions & 0 deletions src/peer.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ class Peer extends EventEmitter {
this.conn = conn
this.stream = pushable({
onEnd: () => {
// close readable side of the stream
this.conn.reset && this.conn.reset()
this.conn = null
this.stream = null
this.emit('close')
Expand Down

0 comments on commit c6ba48d

Please sign in to comment.