aboutsummaryrefslogtreecommitdiff
path: root/server.js
diff options
context:
space:
mode:
authorEv Bogue <ev@evbogue.com>2019-11-24 11:51:27 -0600
committerEv Bogue <ev@evbogue.com>2019-11-24 11:51:27 -0600
commit7cde50381962971665a8f82a9aeb10b9ee82ae41 (patch)
tree936bb746acfb5bd2f0ef46b1be7d5fd55cbb3897 /server.js
parent79b1c0e953dad37e4f8f97e2fb297a78e876715b (diff)
slow down ads a little
Diffstat (limited to 'server.js')
-rw-r--r--server.js31
1 files changed, 17 insertions, 14 deletions
diff --git a/server.js b/server.js
index 112f899..36a86c0 100644
--- a/server.js
+++ b/server.js
@@ -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