Improvements to enablePing() & tests (#506)

https://github.com/nbd-wtf/nostr-tools/pull/506
This commit is contained in:
Chris McCormick
2025-09-29 21:41:40 +08:00
committed by GitHub
parent c9ff51e278
commit 226d7d07e2
4 changed files with 93 additions and 17 deletions

View File

@@ -14,12 +14,12 @@ export function useWebSocketImplementation(websocketImplementation: any) {
}
export class Relay extends AbstractRelay {
constructor(url: string) {
super(url, { verifyEvent, websocketImplementation: _WebSocket })
constructor(url: string, options?: { enablePing?: boolean }) {
super(url, { verifyEvent, websocketImplementation: _WebSocket, ...options })
}
static async connect(url: string): Promise<Relay> {
const relay = new Relay(url)
static async connect(url: string, options?: { enablePing?: boolean }): Promise<Relay> {
const relay = new Relay(url, options)
await relay.connect()
return relay
}