diff options
author | Holden Rohrer <holden.rohrer@gmail.com> | 2019-12-27 14:23:55 -0500 |
---|---|---|
committer | Holden Rohrer <holden.rohrer@gmail.com> | 2019-12-27 14:23:55 -0500 |
commit | 8277732846f594547a0c8cfde4aa81f21396f393 (patch) | |
tree | 6e8469d3cebe46332ab6dd07642f6f348cad21fc /examples | |
parent | 790a01a32aa37684a5c39e5af6cb17d892212e79 (diff) |
reenabled jarvis tileHandler (responder todo)
Diffstat (limited to 'examples')
-rw-r--r-- | examples/jarvis.js | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/examples/jarvis.js b/examples/jarvis.js index a78024b..8b67961 100644 --- a/examples/jarvis.js +++ b/examples/jarvis.js @@ -13,6 +13,7 @@ function equals(arg1,arg2){ // Just takes the specific case argument of each bei } main.on('open', ()=>{ // Tries to identify itself with a cursor movement + console.log('socket opened'); let coords = [Math.floor(Math.random()*100000+16),Math.floor(Math.random()*100000+16)]; main.cursor(coords); main.on('cursor',detect); @@ -33,23 +34,24 @@ function identity(sender){ var read = new Search(search); var expire = {}; - main.on('tileUpdate', (send, source, tiles) => { console.log(tiles); }); - /*main.on('tileUpdate', (send, source, tiles) => { - console.log('detected update', tiles); - if (send == sender) return; + main.on('tileUpdate', (send, source, tiles) => { + // if (send == sender) return; ::: this may lead to issues later, but for now is used to count its own updates let locs = tilekeys(tiles); for (let i=0; i<locs.length; i++){ let loc = locs[i]; - if (read.has(loc)) clearTimeout(expire[loc]); + if (read.has(loc)){ + clearTimeout(expire[loc]); + delete expire[loc]; + read.del(loc); + } let locspace = new Space(); locspace.fromfetch(tiles, [loc, loc], conform=false); - let results = read.add(locspace); - if (! results) respond(results); - expire[loc] = setTimeout(()=>{read.del(loc)}, 30000); + let results = read.add(loc, locspace); + if (results.length > 0) respond(results); + expire[loc] = setTimeout(() => {read.del(loc)}, 30000); } - - });*/ + }); } function respond(coord){ |