feat: emit closed

This commit is contained in:
2024-01-08 12:53:49 +00:00
parent add3b45fcd
commit cae865a3e7

View File

@ -51,6 +51,7 @@ interface ConnectionEvents {
connected: (wasReconnect: boolean) => void; connected: (wasReconnect: boolean) => void;
event: (sub: string, e: TaggedNostrEvent) => void; event: (sub: string, e: TaggedNostrEvent) => void;
eose: (sub: string) => void; eose: (sub: string) => void;
closed: (sub: string, reason: string) => void;
disconnect: (code: number) => void; disconnect: (code: number) => void;
auth: (challenge: string, relay: string, cb: (ev: NostrEvent) => void) => void; auth: (challenge: string, relay: string, cb: (ev: NostrEvent) => void) => void;
notice: (msg: string) => void; notice: (msg: string) => void;
@ -252,6 +253,10 @@ export class Connection extends EventEmitter<ConnectionEvents> {
this.#log(`NOTICE: ${msg[1]}`); this.#log(`NOTICE: ${msg[1]}`);
break; break;
} }
case "CLOSED": {
this.emit("closed", msg[1] as string, msg[2] as string);
this.#log(`CLOSED: ${msg.slice(1)}`);
}
default: { default: {
this.#log(`Unknown tag: ${tag}`); this.#log(`Unknown tag: ${tag}`);
break; break;