mirror of
https://github.com/nbd-wtf/nostr-tools.git
synced 2025-12-09 00:28:51 +00:00
rename this._push to this._onmessage and use it internally.
This commit is contained in:
@@ -102,12 +102,7 @@ export class AbstractRelay {
|
|||||||
this._connected = false
|
this._connected = false
|
||||||
}
|
}
|
||||||
|
|
||||||
this.ws.onmessage = ev => {
|
this.ws.onmessage = this._onmessage
|
||||||
this.incomingMessageQueue.enqueue(ev.data as string)
|
|
||||||
if (!this.queueRunning) {
|
|
||||||
this.runQueue()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
return this.connectionPromise
|
return this.connectionPromise
|
||||||
@@ -268,10 +263,10 @@ export class AbstractRelay {
|
|||||||
this.ws?.close()
|
this.ws?.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
// this method simulates receiving a message from the websocket
|
// this is the function assigned to this.ws.onmessage
|
||||||
// for testing purposes only
|
// it's exposed for testing and debugging purposes
|
||||||
public _push(msg: string) {
|
public _onmessage(ev: MessageEvent<any>) {
|
||||||
this.incomingMessageQueue.enqueue(msg)
|
this.incomingMessageQueue.enqueue(ev.data as string)
|
||||||
if (!this.queueRunning) {
|
if (!this.queueRunning) {
|
||||||
this.runQueue()
|
this.runQueue()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ const runWith = (relay: AbstractRelay) => async () => {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
for (let e = 0; e < messages.length; e++) {
|
for (let e = 0; e < messages.length; e++) {
|
||||||
relay._push(messages[e])
|
relay._onmessage({ data: messages[e] } as any)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user