Commit 43408c7f5223544e1c793dc259f4e86354b744bc
Fix keepalive
cel committed on 7/27/2017, 4:11:20 AMParent: b6bb96e631017a8e97aaa30b97cc921414e9b440
Files changed
index.js | changed |
index.js | ||
---|---|---|
@@ -30,8 +30,15 @@ | ||
30 | 30 … | return sink |
31 | 31 … | } |
32 | 32 … | } |
33 | 33 … | |
34 … | +function fork(before, after) { | |
35 … | + return function () { | |
36 … | + before.apply(this, arguments) | |
37 … | + after.apply(this, arguments) | |
38 … | + } | |
39 … | +} | |
40 … | + | |
34 | 41 … | module.exports = function (opts, cb) { |
35 | 42 … | if (typeof opts === 'function') cb = opts, opts = null |
36 | 43 … | opts = opts || {} |
37 | 44 … | var config = createConfig(process.env.ssb_appname, opts) |
@@ -74,9 +81,12 @@ | ||
74 | 81 … | sbot.id = '@'+stream.remote.toString('base64')+'.ed25519' |
75 | 82 … | if (sbot.blobs && sbot.blobs.add) sbot.blobs.add = fixAddBlob(sbot.blobs.add) |
76 | 83 … | pull(stream, sbot.createStream(), stream) |
77 | 84 … | delete config.keys |
78 | - setTimeout(sbot.whoami, 15e3) // keepalive | |
85 … | + var keepalive = setInterval(sbot.whoami, 1e3) | |
86 … | + sbot.close = fork(sbot.close, function () { | |
87 … | + clearInterval(keepalive) | |
88 … | + }) | |
79 | 89 … | cb(null, sbot, config) |
80 | 90 … | }) |
81 | 91 … | }(remote)) |
82 | 92 … | } |
Built with git-ssb-web