*Add peer-open and peer-remove events
This commit is contained in:
parent
9c7dc7dad8
commit
8d57c62994
|
@ -1 +1 @@
|
|||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAAA,OAAO,YAAY,MAAM,QAAQ,CAAC;AAoBlC,MAAM,CAAC,OAAO,OAAO,QAAS,SAAQ,YAAY;IAC9C,OAAO,CAAC,EAAE,CAAS;IACnB,OAAO,CAAC,GAAG,CAAS;IACpB,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,GAAG,CAAM;IACjB,OAAO,CAAC,KAAK,CAAM;gBAEP,EACI,OAAkB,EAClB,GAAS,EACT,aAAiB,EACjB,EAA2B,EAC3B,KAAY,EACf;;;;;;KAAK;IAkBlB,OAAO,CAAC,aAAa;IAwBrB,OAAO,CAAC,SAAS;IAmCjB,SAAS,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,SAAW;CActC"}
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAAA,OAAO,YAAY,MAAM,QAAQ,CAAC;AAoBlC,MAAM,CAAC,OAAO,OAAO,QAAS,SAAQ,YAAY;IAC9C,OAAO,CAAC,EAAE,CAAS;IACnB,OAAO,CAAC,GAAG,CAAS;IACpB,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,GAAG,CAAM;IACjB,OAAO,CAAC,KAAK,CAAM;gBAEP,EACI,OAAkB,EAClB,GAAS,EACT,aAAiB,EACjB,EAA2B,EAC3B,KAAY,EACf;;;;;;KAAK;IAkBlB,OAAO,CAAC,aAAa;IAwBrB,OAAO,CAAC,SAAS;IA2CjB,SAAS,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,SAAW;CActC"}
|
|
@ -77,9 +77,17 @@ export default class DHTFlood extends EventEmitter {
|
|||
const mux = Protomux.from(peer);
|
||||
let chan: any;
|
||||
|
||||
const self = this;
|
||||
|
||||
if (!mux.opened({protocol: PROTOCOL})) {
|
||||
chan = mux.createChannel({
|
||||
protocol: PROTOCOL,
|
||||
async onopen() {
|
||||
self.emit('peer-open', peer)
|
||||
},
|
||||
async ondestroy() {
|
||||
self.emit('peer-remove', peer)
|
||||
},
|
||||
});
|
||||
peer[FLOOD_SYMBOL] = chan;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue