[web] How do Browser games implement 'tickers'?

Started by
39 comments, last by louissan 13 years ago
For lack of a better word, how are 'tickers' (things that make time tick by and events happen in browser games) implemented?

I could think of a few ways.

-cronjob (linux dependent and useless to me since i run a windows server)
-server itself has something running like a 'update.php' page with a meta/jvs refresh timer
-windows scheduler or something which isn't really any different from option #2
-cgi script (not really sure how to do this but it seems like it might be the most common solution. that's just a guess though)

I was hoping for a more logical solution than having to have a webpage open on my server in order for my game world to be alive.
Advertisement
Cron.
As I said, I'm running a Windows server.
CronW? Its cron for windows.

Also, I've never used a windows server before, but supposedly there is a task scheduler you can set up.
Depends how often they happen, if it's happening often why not just make an executable that runs as a service do it every X amount of time you need it to, otherwise if it's infrequent scheduled tasks are what you're looking for
It's a Browser based game that updates every minute.

How would I go about writing this type of executable? Do you mean like a c++ application that loops on a timer and calls update.php every minute? If so, how do I call a webpage with C++? Is that a CGI thing?
The language wouldn't matter, but you could just throw something together to make URLRequest every minute on 127.0.0.1/whatever.php

SO has how to do it in C++ with libcurl: http://stackoverflow.com/questions/1011339/how-do-you-make-a-http-request-with-c
Quote:Original post by sooner123
It's a Browser based game that updates every minute.

How would I go about writing this type of executable? Do you mean like a c++ application that loops on a timer and calls update.php every minute? If so, how do I call a webpage with C++? Is that a CGI thing?


Ask yourself this:

Does it really matter if it updates or not while noone is playing ?

You can easily have it run as many updates as necessary to catch up once a player accesses the game.
[size="1"]I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!
I've considered that option but I don't like it for a few reasons related to workload distribution.

What is the way this is usually done? Like say for large scale games like.. Farmville or Travian or any number of Browser based games with an updating world.
If I had to implement such a feature, I'd be in favor of what SimonForsman proposed. It seems unnecessary to have your server working away, when no one is playing. I assume, like the games you mentioned, you'll require some form of registration to play? I would imagine the standard practice would be to save the time the users game was last updated and, the next time they launched the game, calculate the number of updates that would've happened and perform them.

If you wanted to entertain an extreme example, say you have 1,000,000 users. If you updated every minute, you'd have to update all 1,000,000 users at once, even if there were only 2 users currently playing. If you had a lot of game state data, that could be hell on your server, and annoy for those 2 user. If you allow interaction between users (as in a farm style game), and one of the users isn't logged in, I would just update their game if/when the other user interacts with it.

This topic is closed to new replies.

Advertisement