Qiao
Qiao

Reputation: 17049

Event triggering in server-side scripts

In SO, when your question got answer. or you got new badge, event is triggered. Or when you got new PM in forum, it also lets you know by alerting message.

You see message that something happened with your account when you enter site for first time after this event.

How is this implemented? How do scripts know, that they have something new to show you?

Upvotes: 2

Views: 454

Answers (3)

Your Common Sense
Your Common Sense

Reputation: 157981

As an answer to your last comment
There are several tecniques to mark events as a 'new'. It can be another field in the database table, of boolean type: telling if event was shown to user or not. Or - easiest one - just a time of last user's visit being recorded in the session, and then al upcoming event's time being compared with it.

Upvotes: 1

Residuum
Residuum

Reputation: 12064

The programming technique you are looking for is called Comet. The link to wikipedia describes some implementations of that, but the easiest way is to make an XMLHttpRequest with a long timeout and only return data on change.

Upvotes: 3

Vincent Ramdhanie
Vincent Ramdhanie

Reputation: 103145

The event happens when another person does something like vote on your answer or question. This is recorded on the server side.

When you log on to the site the fact that some events occured while you were away can be determined from looking up the database for these records.

While you are on the site it is possible for the page to periodically poll the server for changes. So its not really the server that the event is triggered on.

Upvotes: 0

Related Questions