*Move listenConnections call to private method that will do a backoff connection after returning
This commit is contained in:
parent
7d031231a3
commit
b76aa38f76
21
src/index.ts
21
src/index.ts
|
@ -50,13 +50,7 @@ export class SwarmClient extends Client {
|
|||
return this._ready;
|
||||
}
|
||||
|
||||
this.connectModule(
|
||||
"listenConnections",
|
||||
{ swarm: this.swarm },
|
||||
async (socketId: any) => {
|
||||
this.emit("connection", await createSocket(socketId));
|
||||
}
|
||||
);
|
||||
this._listen();
|
||||
|
||||
this._ready = this.callModuleReturn("ready", { swarm: this.swarm });
|
||||
|
||||
|
@ -80,6 +74,19 @@ export class SwarmClient extends Client {
|
|||
await this.ready();
|
||||
}
|
||||
|
||||
private async _listen() {
|
||||
const connect = this.connectModule(
|
||||
"listenConnections",
|
||||
{ swarm: this.swarm },
|
||||
async (socketId: any) => {
|
||||
this.emit("connection", await createSocket(socketId));
|
||||
}
|
||||
);
|
||||
|
||||
await connect[1];
|
||||
this._connectBackoff.backoff();
|
||||
}
|
||||
|
||||
public async addRelay(pubkey: string): Promise<void> {
|
||||
return this.callModuleReturn("addRelay", { pubkey, swarm: this.swarm });
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue