Skip to content
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

Merged
merged 6 commits into from
Sep 22, 2019
Merged

Live player count #197

merged 6 commits into from
Sep 22, 2019

Conversation

Rackover
Copy link
Member

Displays live player count and game count on homepage, taken from python server API

@@ -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';

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🐒

Copy link
Member Author

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 Show resolved Hide resolved
public/js/app/counter.js Outdated Show resolved Hide resolved
public/js/app/counter.js Show resolved Hide resolved
console.log($("#game_counter").parent());
$.get('lobby_api', { resource: "games"}, function (body) {
let entries = body;
if ($("#game_counter").text() == entries.length.toString()) return;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-//-

public/styles/site/index.sass Outdated Show resolved Hide resolved
routes/lobby_api.js Outdated Show resolved Hide resolved
public/js/app/counter.js Outdated Show resolved Hide resolved
public/js/app/counter.js Outdated Show resolved Hide resolved
request(process.env.LOBBY_API_URL + '/'+req.query.resource, function (error, response, body) {
res.send(JSON.parse(body));
});
};
Copy link

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CORS Policy

Copy link

@norraxx norraxx left a 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.

  1. less queries to db
  2. you'll have data already from cache and don't have to show 0 after opening the page.

@Rackover
Copy link
Member Author

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.

  1. less queries to db
  2. 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!
Unless we fake it by adding random deviations to a cached number, but this will be easy to tell apart...

Also, no database is involved in that query. It's using the python server API.

@Rackover
Copy link
Member Author

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.

@Rackover Rackover merged commit efa203d into develop Sep 22, 2019
@Brutus5000 Brutus5000 deleted the live_player_count branch February 24, 2020 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants