From d146dbbab184a6e78f58bda9f997d68bac34b240 Mon Sep 17 00:00:00 2001
From: Holden Rohrer
Date: Tue, 14 Jan 2020 21:05:59 -0500
Subject: moved exclusions to responder
---
examples/jarvis.js | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
(limited to 'examples')
diff --git a/examples/jarvis.js b/examples/jarvis.js
index 0df6151..157808f 100644
--- a/examples/jarvis.js
+++ b/examples/jarvis.js
@@ -138,10 +138,8 @@ var search = new Space();
search.adhoc('jarvis'); // The search space is the word jarvis, so whenever that's caught, a relevant function can be called.
var read = new Search(search);
var expire = {};
-var limits = []; // an array of senders within the last 5 seconds to act as a 'rate limiter'
function detectPrompt(send, tiles, locs){ // tries to detect the prompt ('jarvis') and calls respond if found.
- if (limits.indexOf(send) >= 0) return;
for (let i=0; i 0) respond(results);
+ if (results.length > 0) respond(results, send);
expire[loc] = setTimeout(() => {read.del(loc); delete expire[loc];}, 30000);
}
limits.push(send);
- setTimeout(() => {limits.splice(limits.indexOf(send))}, 5*1000);
}
let response = new Space();
response.adhoc('yes, my liege');
-function respond(coord){
+var limits = []; // an array of senders within the last 5 seconds to act as a 'rate limiter'
+function respond(coord, send){
+ if (limits.indexOf(send) >= 0) return;
console.log('called at', coord);
callct += 1;
response.loc = coord;
writes.enqueue(response.towrite().concat(notifRefresh()));
read.update(response);
+ setTimeout(() => {limits.splice(limits.indexOf(send))}, 5*1000);
}
--
cgit
From 2cc02e19410ea9a97a76480d84e0dc3be0efe312 Mon Sep 17 00:00:00 2001
From: Holden Rohrer
Date: Sat, 18 Jan 2020 08:40:38 -0500
Subject: moved jarvis to schedule
---
examples/jarvis.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
(limited to 'examples')
diff --git a/examples/jarvis.js b/examples/jarvis.js
index 157808f..14bbaf7 100644
--- a/examples/jarvis.js
+++ b/examples/jarvis.js
@@ -7,7 +7,7 @@ const ms = require('../utils/measurespace');
const vec = require('../utils/vec');
const comb = require('../utils/comb');
const Search = require('../tools/search');
-const Queue = require('../tools/queue');
+const sched = require('../tools/schedule');
const ri = require('../utils/rectintersect');
//// Basic handling on open and close of the socket
@@ -78,7 +78,7 @@ function tileHandler(send, source, tiles){
}
//// "userspace" functions for responses, like to tileUpdates
-var writes = new Queue(1000, 200, (elems) => main.write(elems));
+var writes = new sched.Queue(1000, 200, (elems) => main.write(elems));
var command = 'jarvis'
var sig = 'feynmansfedora'
--
cgit