nedap server: rate limiting

This commit is contained in:
Astro 2011-04-22 17:40:39 +02:00
parent bb48073a7c
commit 8630497688
2 changed files with 14 additions and 4 deletions

6
TODO
View File

@ -23,11 +23,11 @@
* a8 -(0%)- irc-Web gateway (asto finded das blöd. Aber vllt. hat jemand keinen irc-Client zur Hand * a8 -(0%)- irc-Web gateway (asto finded das blöd. Aber vllt. hat jemand keinen irc-Client zur Hand
* astro -(0%)- Google-Joker: ggf. anderer Name; Spieler darf für 30s bei Google suchen und im Web klicken. * astro -(0%)- Google-Joker: ggf. anderer Name; Spieler darf für 30s bei Google suchen und im Web klicken.
Dafür gibt es ein unbeschriftetes Keyboard mit engl. oder dt. Tastaturlayout Dafür gibt es ein unbeschriftetes Keyboard mit engl. oder dt. Tastaturlayout
* astro -(10%)- Pusher-Joker: Spieler gibt die Frage an einen anderen Spieler weiter * astro -(100%)- Shift-Joker: Spieler gibt die Frage an einen anderen Spieler weiter
* astro -(100%)- Wikipedia-Joker: 2 Antworten werden wegen Irrelevanz gelöscht (Logo!) * astro -(100%)- Wikipedia-Joker: 2 Antworten werden wegen Irrelevanz gelöscht (Logo!)
* astro -(100%)- vote.c3d2.de & IRC auf Startscreen * astro -(100%)- vote.c3d2.de & IRC auf Startscreen
* astro -( 0%)- nedap-joker rate limiting * astro -( 99%)- nedap-joker rate limiting
* astro -( 70%)- nedap-joker vote w/ token * astro -(100%)- nedap-joker vote w/ token
== Ideen == == Ideen ==
* - -()- Eliza-Joker: Frage kann wie bei Eliza per Text-Chat erörtert werden. Da ist aber der Aufwand für * - -()- Eliza-Joker: Frage kann wie bei Eliza per Text-Chat erörtert werden. Da ist aber der Aufwand für

View File

@ -39,6 +39,16 @@ var Token = {
} }
}; };
var updateBackendTimeout;
function updateBackend() {
if (!updateBackendTimeout) {
updateBackendTimeout = setTimeout(function() {
backend.send(JSON.stringify({ scores: scores }));
updateBackendTimeout = undefined;
}, 50);
}
}
function nedap(app) { function nedap(app) {
app.get('/', function(req, res) { app.get('/', function(req, res) {
if (question && answers) { if (question && answers) {
@ -80,7 +90,7 @@ console.log({question:question,answers:answers})
var i = parseInt(a, 10); var i = parseInt(a, 10);
if (scores && i < scores.length && Token.validate(req.body.token)) { if (scores && i < scores.length && Token.validate(req.body.token)) {
scores[i]++; scores[i]++;
backend.send(JSON.stringify({ scores: scores })); updateBackend();
res.writeHead(303, { 'Content-type': 'text/html', res.writeHead(303, { 'Content-type': 'text/html',
'Location': '/thanks' }); 'Location': '/thanks' });