From fe04cbe10d9036846f576eca69c41115df51112f Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Mon, 6 Feb 2023 03:13:32 -0500 Subject: [PATCH] *On the ready method, setup a connection to the swarm module to listen for new connections --- src/index.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index 5855692..aeea1a7 100644 --- a/src/index.ts +++ b/src/index.ts @@ -33,8 +33,16 @@ export class SwarmClient extends Client { async init(): Promise { return this.callModuleReturn("init", { swarm: this.swarm }); } - async ready(): Promise { - return this.callModuleReturn("ready", { swarm: this.swarm }); + async ready(): Promise { + await this.callModuleReturn("ready", { swarm: this.swarm }); + + this.connectModule( + "listenConnections", + { swarm: this.swarm }, + (socketId: any) => { + this.emit("connection", createClient(socketId)); + } + ); } public async addRelay(pubkey: string): Promise {