mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-06-19 12:11:22 +00:00
fix: connection emits (#352)
* fix: add connection tracking events * chore: update dependencies
This commit is contained in:
16
README.md
16
README.md
@ -313,13 +313,25 @@ unless they are performing a specific action. See [peer discovery and auto dial]
|
|||||||
|
|
||||||
##### `libp2p.on('peer:connect', (peer) => {})`
|
##### `libp2p.on('peer:connect', (peer) => {})`
|
||||||
|
|
||||||
> We connected to a new peer
|
> We have a new muxed connection to a peer
|
||||||
|
|
||||||
- `peer`: instance of [PeerInfo][]
|
- `peer`: instance of [PeerInfo][]
|
||||||
|
|
||||||
##### `libp2p.on('peer:disconnect', (peer) => {})`
|
##### `libp2p.on('peer:disconnect', (peer) => {})`
|
||||||
|
|
||||||
> We disconnected from Peer
|
> We have closed a connection to a peer
|
||||||
|
|
||||||
|
- `peer`: instance of [PeerInfo][]
|
||||||
|
|
||||||
|
##### `libp2p.on('connection:start', (peer) => {})`
|
||||||
|
|
||||||
|
> We created a new connection to a peer
|
||||||
|
|
||||||
|
- `peer`: instance of [PeerInfo][]
|
||||||
|
|
||||||
|
##### `libp2p.on('connection:end', (peer) => {})`
|
||||||
|
|
||||||
|
> We closed a connection to a peer
|
||||||
|
|
||||||
- `peer`: instance of [PeerInfo][]
|
- `peer`: instance of [PeerInfo][]
|
||||||
|
|
||||||
|
@ -42,10 +42,10 @@
|
|||||||
"debug": "^4.1.1",
|
"debug": "^4.1.1",
|
||||||
"err-code": "^1.1.2",
|
"err-code": "^1.1.2",
|
||||||
"fsm-event": "^2.1.0",
|
"fsm-event": "^2.1.0",
|
||||||
"libp2p-connection-manager": "~0.0.2",
|
"libp2p-connection-manager": "~0.1.0",
|
||||||
"libp2p-floodsub": "~0.15.8",
|
"libp2p-floodsub": "~0.15.8",
|
||||||
"libp2p-ping": "~0.8.5",
|
"libp2p-ping": "~0.8.5",
|
||||||
"libp2p-switch": "~0.42.8",
|
"libp2p-switch": "~0.42.9",
|
||||||
"libp2p-websockets": "~0.12.2",
|
"libp2p-websockets": "~0.12.2",
|
||||||
"mafmt": "^6.0.7",
|
"mafmt": "^6.0.7",
|
||||||
"multiaddr": "^6.0.6",
|
"multiaddr": "^6.0.6",
|
||||||
|
@ -85,6 +85,14 @@ class Node extends EventEmitter {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Events for anytime connections are created/removed
|
||||||
|
this._switch.on('connection:start', (peerInfo) => {
|
||||||
|
this.emit('connection:start', peerInfo)
|
||||||
|
})
|
||||||
|
this._switch.on('connection:end', (peerInfo) => {
|
||||||
|
this.emit('connection:end', peerInfo)
|
||||||
|
})
|
||||||
|
|
||||||
// Attach crypto channels
|
// Attach crypto channels
|
||||||
if (this._modules.connEncryption) {
|
if (this._modules.connEncryption) {
|
||||||
let cryptos = this._modules.connEncryption
|
let cryptos = this._modules.connEncryption
|
||||||
|
Reference in New Issue
Block a user