nostr-tools 0.8.1 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/relay.js +10 -5
package/package.json
CHANGED
package/relay.js
CHANGED
|
@@ -13,7 +13,7 @@ export function normalizeRelayURL(url) {
|
|
|
13
13
|
export function relayConnect(url, onNotice) {
|
|
14
14
|
url = normalizeRelayURL(url)
|
|
15
15
|
|
|
16
|
-
var ws, resolveOpen, untilOpen
|
|
16
|
+
var ws, resolveOpen, untilOpen, wasClosed
|
|
17
17
|
var openSubs = {}
|
|
18
18
|
let attemptNumber = 1
|
|
19
19
|
let nextAttemptSeconds = 1
|
|
@@ -34,10 +34,13 @@ export function relayConnect(url, onNotice) {
|
|
|
34
34
|
resolveOpen()
|
|
35
35
|
|
|
36
36
|
// restablish old subscriptions
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
let
|
|
40
|
-
|
|
37
|
+
if (wasClosed) {
|
|
38
|
+
wasClosed = false
|
|
39
|
+
for (let channel in openSubs) {
|
|
40
|
+
let filters = openSubs[channel]
|
|
41
|
+
let cb = channels[channel]
|
|
42
|
+
sub({cb, filter: filters}, channel)
|
|
43
|
+
}
|
|
41
44
|
}
|
|
42
45
|
}
|
|
43
46
|
ws.onerror = () => {
|
|
@@ -58,6 +61,8 @@ export function relayConnect(url, onNotice) {
|
|
|
58
61
|
connect()
|
|
59
62
|
} catch (err) {}
|
|
60
63
|
}, nextAttemptSeconds * 1000)
|
|
64
|
+
|
|
65
|
+
wasClosed = true
|
|
61
66
|
}
|
|
62
67
|
|
|
63
68
|
ws.onmessage = async e => {
|