diff options
author | Ev Bogue <ev@evbogue.com> | 2019-11-24 11:51:27 -0600 |
---|---|---|
committer | Ev Bogue <ev@evbogue.com> | 2019-11-24 11:51:27 -0600 |
commit | 7cde50381962971665a8f82a9aeb10b9ee82ae41 (patch) | |
tree | 936bb746acfb5bd2f0ef46b1be7d5fd55cbb3897 /server.js | |
parent | 79b1c0e953dad37e4f8f97e2fb297a78e876715b (diff) |
slow down ads a little
Diffstat (limited to 'server.js')
-rw-r--r-- | server.js | 31 |
1 files changed, 17 insertions, 14 deletions
@@ -46,20 +46,23 @@ bog.keys().then(key => { if (unboxedreq.seq === msg.seq) { //console.log(unboxedreq.author + '\'s feed is identical, sending nothing to client') //commment this section out to disable ads - console.log(unboxedreq.author + '\'s feed is identical, sending an ad to ' + req.requester) - var ad = JSON.stringify({ - author: key.publicKey, - name: 'http://bogbook.com/', - content: adContents[Math.floor(Math.random() * adContents.length)], - timestamp: Date.now() - }) - bog.box(ad, req.requester, key).then(boxed => { - obj = { - requester: key.publicKey, - box: boxed - } - ws.send(JSON.stringify(obj)) - }) + console.log(unboxedreq.author + '\'s feed is identical') + if (Math.floor(Math.random() * 4) == 2) { + console.log('sending an ad to ' + req.requester) + var ad = JSON.stringify({ + author: key.publicKey, + name: 'http://bogbook.com/', + content: adContents[Math.floor(Math.random() * adContents.length)], + timestamp: Date.now() + }) + bog.box(ad, req.requester, key).then(boxed => { + obj = { + requester: key.publicKey, + box: boxed + } + ws.send(JSON.stringify(obj)) + }) + } } if (unboxedreq.seq > msg.seq) { // right now the client is still sending the entire log, which works just fine but isn't optimal |