diff --git a/src/messages/signedMessages/handshakeDone.ts b/src/messages/signedMessages/handshakeDone.ts index ae7f122..7830bcf 100644 --- a/src/messages/signedMessages/handshakeDone.ts +++ b/src/messages/signedMessages/handshakeDone.ts @@ -60,4 +60,5 @@ export default async function ( p2p.sendPublicPeersToPeer(p, [peer]); } } + p2p.emit("peerConnected", peer); } diff --git a/src/service/p2p.ts b/src/service/p2p.ts index 37b9699..73fe25c 100644 --- a/src/service/p2p.ts +++ b/src/service/p2p.ts @@ -26,8 +26,9 @@ import { createTransportSocket, } from "#transports/index.js"; import messages from "#messages/index.js"; +import { EventEmitter } from "events"; -export class P2PService { +export class P2PService extends EventEmitter { private logger: Logger; private nodeKeyPair: KeyPairEd25519; private localNodeId?: NodeId; @@ -39,6 +40,7 @@ export class P2PService { >; constructor(node: S5Node) { + super(); this._node = node; this._networkId = node.config.p2p?.network; this.nodeKeyPair = node.config.keyPair;