-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Live player count #197
Live player count #197
Conversation
@@ -6,7 +6,7 @@ exports = module.exports = function(req, res) { | |||
// locals.section is used to set the currently selected | |||
// item in the header navigation. | |||
locals.section = 'home'; | |||
|
|||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🐒
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
???
public/js/app/counter.js
Outdated
console.log($("#game_counter").parent()); | ||
$.get('lobby_api', { resource: "games"}, function (body) { | ||
let entries = body; | ||
if ($("#game_counter").text() == entries.length.toString()) return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-//-
request(process.env.LOBBY_API_URL + '/'+req.query.resource, function (error, response, body) { | ||
res.send(JSON.parse(body)); | ||
}); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do I understand right, that we're asking our website to ask the api, not the api directly?
Is there any reason to create such unnecessary load?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CORS Policy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, i think, i think... you can create cache system, ask player count on server side, store result to cache, and read it from cache to outside world.
- less queries to db
- you'll have data already from cache and don't have to show 0 after opening the page.
We don't want caching for this, because we want the player count to be LIVE on the webpage! Also, no database is involved in that query. It's using the python server API. |
The "show 0" thing I'm going to remove, as I'm said on zulip i'm not quite done yet. Thats why there is a unused class in sass. For now. |
Displays live player count and game count on homepage, taken from python server API