0

Hi there,
in twitter and facebook when some of your friends/follows makes new post, your page gets updated via ajax.

any ideas how it is implemented? i need the best concept/idea, not the code :]

thnx in advance

2
Contributors
8
Replies
9
Views
6 Years
Discussion Span
Last Post by McLaren
0

don't know how it is done but I can try to guess.

You should make some timer in your page, which periodically checks a facebook for new posts. If there is new ones, then update your page :)

Edit: don't know how to check for those new posts in facebook, but I heard that there is some API so I guess you need to be familiar with it.

Edited by McLaren: n/a

0

First thing came my mind also was periodically checking the server for new posts with ajax, but in my opinion it loads the server and database.
My suggestion is that when someone posts, server looks for online friends and performs "send_new_post" function. On the client side there is a javascript function "on_post_arrival" that will paste new arrived post. The question is how? :)
Is it actually possible to do it without periodically sending requests?

P.S.: when I wrote "in twitter and facebook" I meant them as examples)

Edited by Acute: n/a

0

Why is it called Comet:

In March 2006, software engineer Alex Russell coined the term Comet in a post on his personal blog.[17] The new term was a play on Ajax (Ajax and Comet both being household cleaners, common in the USA).

:D

this is from wikipedia http://en.wikipedia.org/wiki/Comet_(programming)

For me also when I didn't know about ajax it also made me associations with cleaner :D

0

Thxn!))) Shit, I was implementing the same thing)) well, almost the same thing))) But, in my implementation the main disadvantage is that I have to create "userID".php file for each registered user, since single php file can't process many many files simultaneously.(can it?)

0

But, in my implementation the main disadvantage is that I have to create "userID".php file for each registered user, since single php file can't process many many files simultaneously.(can it?)

I think it should be possible. Creating php files for every user looks not that good - what if you have 100K users? :)

I found here is decent tutorial:

http://www.zeitoun.net/articles/comet_and_php/start

<?php
 
  while(1) {
    echo '<script type="text/javascript">';
    echo 'comet.printServerTime('.time().');';
    echo '</script>';
    flush(); // used to send the echoed data to the client
    sleep(1); // a little break to unload the server CPU
  }
 
  ?>

So I think server should somehow check what users are logged in at every cycle, and send to them data.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.