Add event for multiaddresses changed #2
@@ -153,6 +153,15 @@ export class Libp2pComponent implements ILibp2pComponent {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Multiaddresses changed event
|
||||||
|
this.eventEmitter.addListener('onMultiaddressesChanged', ({ multiaddrs }: { multiaddrs: string[] }) => {
|
||||||
|
logger.debug('[Libp2pComponent] Multiaddresses changed:', multiaddrs);
|
||||||
|
this._multiaddrs = multiaddrs.map((addr: string) => new SimpleMultiaddr(addr));
|
||||||
|
this.emit('multiaddresses:changed', {
|
||||||
|
multiaddrs: this._multiaddrs,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// Connection events
|
// Connection events
|
||||||
this.eventEmitter.addListener(
|
this.eventEmitter.addListener(
|
||||||
'onConnectionStatus',
|
'onConnectionStatus',
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ export interface Libp2pEvents {
|
|||||||
'connection:open': CustomEvent<Connection>;
|
'connection:open': CustomEvent<Connection>;
|
||||||
'connection:close': CustomEvent<Connection>;
|
'connection:close': CustomEvent<Connection>;
|
||||||
'self:peer:update': CustomEvent<{ peerId: PeerId; multiaddrs: Multiaddr[] }>;
|
'self:peer:update': CustomEvent<{ peerId: PeerId; multiaddrs: Multiaddr[] }>;
|
||||||
|
'multiaddresses:changed': CustomEvent<{ multiaddrs: Multiaddr[] }>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Libp2pOptions {
|
export interface Libp2pOptions {
|
||||||
|
|||||||
Reference in New Issue
Block a user