git ssb

2+

cel / ssb-party



Commit 43408c7f5223544e1c793dc259f4e86354b744bc

Fix keepalive

cel committed on 7/27/2017, 4:11:20 AM
Parent: b6bb96e631017a8e97aaa30b97cc921414e9b440

Files changed

index.jschanged
index.jsView
@@ -30,8 +30,15 @@
3030 return sink
3131 }
3232 }
3333
34 +function fork(before, after) {
35 + return function () {
36 + before.apply(this, arguments)
37 + after.apply(this, arguments)
38 + }
39 +}
40 +
3441 module.exports = function (opts, cb) {
3542 if (typeof opts === 'function') cb = opts, opts = null
3643 opts = opts || {}
3744 var config = createConfig(process.env.ssb_appname, opts)
@@ -74,9 +81,12 @@
7481 sbot.id = '@'+stream.remote.toString('base64')+'.ed25519'
7582 if (sbot.blobs && sbot.blobs.add) sbot.blobs.add = fixAddBlob(sbot.blobs.add)
7683 pull(stream, sbot.createStream(), stream)
7784 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 + })
7989 cb(null, sbot, config)
8090 })
8191 }(remote))
8292 }

Built with git-ssb-web