|
|||||||
New to SitePoint Forums? Register here for free!
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
SitePoint Guru
![]() ![]() ![]() ![]() ![]() Join Date: Sep 2007
Posts: 841
|
Reloading certain data
I have a chatroom and a custom made chatroom list that displays chatrooms and next to the name the amount of users currently in the room, it pulls this information from a mysql database. I was wondering is it possible to reload just the amount of users in the chatroom only when the data is changed. I was thinking of automatically refreshing it every 10 seconds but that would take alot of server load. I would like to do this dynamically.
thanks. |
|
|
|
|
|
#2 |
|
SitePoint Evangelist
![]() ![]() ![]() ![]() Join Date: Oct 2009
Posts: 454
|
Yes.
Modern chats are all based on AJAX technic, which don't reload page at all, but sends requests to the server and recieves data. It's all written in javascript though. And it sends requests every, say 10 sec too. |
|
|
|
|
|
#3 |
|
SitePoint Guru
![]() ![]() ![]() ![]() ![]() Join Date: Sep 2007
Posts: 841
|
wouldnt requests every 10 seconds slow down my server by far if i have like 300 users connected and all trying to receive data?
|
|
|
|
|
|
#4 |
|
Previously, SilverBulletUK.
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Apr 2008
Location: North-East, UK.
Posts: 2,917
|
Much less so than a full page refresh for 300 users every 10 seconds.
![]() |
|
|
|
|
|
#5 |
|
SitePoint Evangelist
![]() ![]() ![]() ![]() Join Date: Oct 2009
Posts: 454
|
No, it wouldn't. Common server can handle thousands of requests.
Room's population is't that critical, so, it can be refreshed every 1 min |
|
|
|
|
|
#6 |
|
Previously, SilverBulletUK.
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Apr 2008
Location: North-East, UK.
Posts: 2,917
|
Personally, I think 10 seconds is way too long for a chat application, never mind a minute.
A large delay is hardly conducive to having a conversation, hence the popularity of Instant Messenger applications. Make this element configurable in your application, you maybe pleasantly surprised. |
|
|
|
|
|
#7 |
|
SitePoint Guru
![]() ![]() ![]() ![]() ![]() Join Date: Sep 2007
Posts: 841
|
can someone please supply me with a base ajax code?
|
|
|
|
|
|
#8 |
|
Previously, SilverBulletUK.
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Apr 2008
Location: North-East, UK.
Posts: 2,917
|
If you're using a JS framework, many provide an example. Check out jQuery or MooTools et al.
|
|
|
|
|
|
#9 |
|
SitePoint Guru
![]() ![]() ![]() ![]() ![]() Join Date: Dec 2005
Posts: 637
|
A very good go for ajax click here
|
|
|
|
|
|
#10 |
|
Floridiot
![]() ![]() ![]() ![]() ![]() Join Date: Mar 2004
Location: Clearwater, FL
Posts: 676
|
If you seriously anticipate that many users being connected at one time you need to abandon the idea of a browser based chat and look into a real application for chat.
There is a lot of overhead with HTTP compared to something designed to have numerous constantly connected systems waiting for responses from a central server and occasionally sending messages. If you are determined to stay in the browser, at least look at using Java (as in the compiled applets, *.jar files, not javascript or *.js files) or Flash. At least they can be setup to conenct to a socket server and listen constantly. |
|
|
|
|
|
#11 |
|
SitePoint Enthusiast
![]() Join Date: May 2005
Location: Hamburg, Germany
Posts: 53
|
As joebert said: Browser-based chat just sucks, sorry.
|
|
|
|
|
|
#12 |
|
SitePoint Guru
![]() ![]() ![]() ![]() ![]() Join Date: Oct 2005
Posts: 975
|
what i do is
make a function and use ajax to call it every x second appending random number to called url.... works and simple and one step further u can add cache feature as well...which will improve performance.... |
|
|
|
![]() |
| Bookmarks |
«
Previous Thread
|
Next Thread
»
| Thread Tools | |
| Display Modes | |
|
|
|
All times are GMT -7. The time now is 01:57.










Linear Mode
