aboutsummaryrefslogtreecommitdiff
path: root/server.js
diff options
context:
space:
mode:
authorEv Bogue <ev@evbogue.com>2020-01-11 11:10:20 -0600
committerEv Bogue <ev@evbogue.com>2020-01-11 11:10:20 -0600
commitbca1b99d3a844c7ed6b956be20b026dd3666b188 (patch)
tree8f07c775f466f0070bb0a4737afda28b5be50b80 /server.js
parentdccfda7a227fdcf834a3b5e167f30af53e6c6507 (diff)
this seems to improve sync speed
Diffstat (limited to 'server.js')
-rw-r--r--server.js8
1 files changed, 7 insertions, 1 deletions
diff --git a/server.js b/server.js
index c1632f0..b022ac0 100644
--- a/server.js
+++ b/server.js
@@ -105,8 +105,10 @@ bog.keys().then(key => {
wserve.on('connection', function (ws) {
ws.on('message', function (message) {
var req = JSON.parse(message)
+ console.log(req)
if (req.sendpub) {
ws.send(key.publicKey)
+ ws.close()
} else {
bog.unbox(req.box, req.requester, key).then(unboxed => {
var unboxedreq = JSON.parse(unboxed)
@@ -119,7 +121,8 @@ bog.keys().then(key => {
bog.open(feed[0]).then(msg => {
if (unboxedreq.seq === msg.seq) {
printFeedIdentical(msg, req)
- }
+ ws.close()
+ }
if (unboxedreq.seq > msg.seq) {
printClientLonger(msg, req)
var reqdiff = JSON.stringify({author: unboxedreq.author, seq: msg.seq})
@@ -129,6 +132,7 @@ bog.keys().then(key => {
box: boxed
}
ws.send(JSON.stringify(obj))
+ ws.close()
})
}
if (unboxedreq.seq < msg.seq) {
@@ -163,6 +167,7 @@ bog.keys().then(key => {
box: boxed
}
ws.send(JSON.stringify(obj))
+ ws.close()
})
}
})
@@ -182,6 +187,7 @@ bog.keys().then(key => {
printUpdateFeed(msg, req)
})
}
+ ws.close()
})
})
}