homepage Welcome to WebmasterWorld Guest from 54.161.155.142
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Facebook chat doesn't have to reload on every page change?
How is this possible?
ryan_b83




msg:4194843
 2:35 am on Sep 1, 2010 (gmt 0)

How is it possible that when you have Facebook chat open (in the browser), when you continue to navigate Facebook it the chat never goes away? It's all in the same window. Do they control the load order or something to make it seem like it never went away?

 

Anyango




msg:4195128
 5:03 pm on Sep 1, 2010 (gmt 0)

iframe ?

ryan_b83




msg:4195214
 7:24 pm on Sep 1, 2010 (gmt 0)

no it doesn't look like an iframe. i think they order the loading starting with the chat. And probably have some crazy caching going on with the rest of the page so the load is minimal.

Demaestro




msg:4195252
 8:20 pm on Sep 1, 2010 (gmt 0)

It's using Ajax logic.

sven1977




msg:4198647
 5:56 pm on Sep 8, 2010 (gmt 0)

It's actually much simpler:
[stackoverflow.com...]

The "links" on the main page are not real <a> links, but rather javascript links that trigger a change in the page's content via AJAX. That way, no page reload needs to be done and the chat can stay wherever it is. You basically stay on the same page and reload it's content when you click on links.

jason_m




msg:4198765
 7:21 pm on Sep 8, 2010 (gmt 0)

i have a follow-up question wrt chats. what is the basic structure of a chat? is it a table in a db maintained for a certain period of time? is it a temporary website created?

have had some trouble wrapping my head around this.

WesleyC




msg:4199795
 3:12 am on Sep 10, 2010 (gmt 0)

I've implemented a few of these. There's actually several ways you can go as far as data storage. Databases are probably the most flexible and easy-to-use, but careful construction of the table and database itself are necessary to prevent the Bottleneck to End All Bottlenecks in high-traffic systems.

A quick and easy alternative is a simple text file, one for each chat "room" for each user. Using PHP logic, append whatever messages come in onto the end of this file. In your AJAX update logic, when a particular user's browser checks for updates, send the contents of the file downstream to the user and empty it. This does not store chat histories, but it does allow a relatively simple (if hard-disk intensive) file-based implementation.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved