tags:

views:

131

answers:

2

On my website users can post comments on a document. Now i want to send a rss feed to the webmasters when a comment is posted. I want the webmaster to be notified like a small pop-up in the right corner of the page. So this is whats happening:

  1. User add comment
  2. system checks a webmaster is logged in
  3. if webmaster is logged in; show pop-up in right corner with the title of the comment in it.

Do you have any suggestions how to accomplish this?

A: 
  1. Setup a javascript timer to call a webservice periodically (every 5 seconds?) if the user is a webmaster. This webservice can determine if a new comment has been added since the last time it was checked. The webservice returns nothing if no new comment or some information about the comment if there is a new one.
  2. If the webservice returns a comment, put that information into a div tag that you have created on your page and make it visible. If you are sure the webmaster is using a modern browser, you can use position:fixed to put this div tag in the upper right corner. If not, you will have to use some javascript to accomplish this.
Keltex
and how do i check whether the webmaster is already noticed about a comment? Do i have to set a flag in the database table?
Martijn
@Martijn: Depends on your scenario. If you only care about comments that have been added during the webmaster's session, you could just store that information in the Session object (maybe in a HashSet<> of ids)
Keltex
A: 

Unless you're using a comet style service to push notifictaions to the webmaster's browser, you're going to need to make a page that polls for new notifications at a pre-defined interval. You can then make an AJAX call to the service and parse the response on to a web page that only the webmaster has access to.

If you're interested in comet (services that can push data to the connected client), you can get a start at Wikipedia:

Comet (programming)

Justin Niessner