*emit setup event to allow setup of a socket before triggering the connection event

*add a link to the parent swarm in the socket to call emit
This commit is contained in:
Derrick Hammer 2023-04-06 09:57:04 -04:00
parent 4541386514
commit a9bc1e3a73
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 6 additions and 1 deletions

View File

@ -165,9 +165,12 @@ export class Socket extends Client {
private syncMutex = new Mutex();
constructor(id: number) {
private swarm: SwarmClient;
constructor(id: number, swarm: SwarmClient) {
super();
this.id = id;
this.swarm = swarm;
}
private _remotePublicKey?: Uint8Array;
@ -194,6 +197,8 @@ export class Socket extends Client {
private async _initSync() {
const mux = Protomux.from(this);
this.swarm.emit("setup", this);
let updateDone = defer();
const [update] = this.connectModule(