Mercurial > hg > rlgwebd
comparison rlgwebd.js @ 113:43340faa061c
RLG-Web server: update timestamps for WebSocket games.
The login timestamps will now be refreshed when games are started via
WebSockets or stopped.
author | John "Elwin" Edwards <elwin@sdf.org> |
---|---|
date | Mon, 16 Jul 2012 10:09:57 -0700 |
parents | 4f2b89e6fde2 |
children | 54979d35611a |
comparison
equal
deleted
inserted
replaced
112:4f2b89e6fde2 | 113:43340faa061c |
---|---|
458 var lkey = wsReq.resourceURL.query["key"]; | 458 var lkey = wsReq.resourceURL.query["key"]; |
459 if (!(lkey in logins)) { | 459 if (!(lkey in logins)) { |
460 wsReq.reject(404, errorcodes[1]); | 460 wsReq.reject(404, errorcodes[1]); |
461 return; | 461 return; |
462 } | 462 } |
463 logins[lkey].ts = new Date(); | |
463 var pname = logins[lkey].name; | 464 var pname = logins[lkey].name; |
464 var dims = [wsReq.resourceURL.query.h, wsReq.resourceURL.query.w]; | 465 var dims = [wsReq.resourceURL.query.h, wsReq.resourceURL.query.w]; |
465 function progcallback(err, fname) { | 466 function progcallback(err, fname) { |
466 if (fname) { | 467 if (fname) { |
467 wsReq.reject(404, errorcodes[4]); | 468 wsReq.reject(404, errorcodes[4]); |
900 function stopgame(res, formdata) { | 901 function stopgame(res, formdata) { |
901 if (!("key" in formdata) || !(formdata["key"] in logins)) { | 902 if (!("key" in formdata) || !(formdata["key"] in logins)) { |
902 sendError(res, 1); | 903 sendError(res, 1); |
903 return; | 904 return; |
904 } | 905 } |
906 /* Update timestamp, because this is an authenticated action. */ | |
907 logins[formdata["key"]].ts = new Date(); | |
905 var pname = logins[formdata["key"]].name; | 908 var pname = logins[formdata["key"]].name; |
906 if (!("g" in formdata) || !(formdata["g"] in games)) { | 909 if (!("g" in formdata) || !(formdata["g"] in games)) { |
907 sendError(res, 2, "No such game."); | 910 sendError(res, 2, "No such game."); |
908 return; | 911 return; |
909 } | 912 } |