should subscribe correctly

This commit is contained in:
Richard Bondi
2021-02-19 09:22:01 -06:00
parent 0c0f9d0e76
commit bdc778314d
2 changed files with 12 additions and 12 deletions

View File

@@ -85,8 +85,7 @@ export function relayConnect(url, onNotice) {
} else {
console.warn(
'got event with invalid signature from ' + url,
event,
id
event
)
}
return
@@ -116,7 +115,8 @@ export function relayConnect(url, onNotice) {
}
}
const sub = async (channel, {cb, filter}) => {
const sub = async ({cb, filter}) => {
const channel = (await sha256(Math.random().toString())).reduce((str, byte) => str + byte.toString(16).padStart(2, '0'), '')
trySend(['REQ', channel, filter])
channels[channel] = cb
@@ -128,9 +128,9 @@ export function relayConnect(url, onNotice) {
return {
url,
sub: sub.bind(null, await sha256(Math.random().toString())),
sub,
async publish(event) {
trySend(JSON.stringify(['EVENT', event]))
trySend(['EVENT', event])
},
close() {
ws.close()