SitePoint Sponsor

User Tag List

Results 1 to 12 of 12
  1. #1
    SitePoint Guru
    Join Date
    Sep 2007
    Posts
    971
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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.
    Animated Chatrooms - www.121chatrooms.net

  2. #2
    Non-Member
    Join Date
    Oct 2009
    Posts
    1,852
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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. #3
    SitePoint Guru
    Join Date
    Sep 2007
    Posts
    971
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    wouldnt requests every 10 seconds slow down my server by far if i have like 300 users connected and all trying to receive data?
    Animated Chatrooms - www.121chatrooms.net

  4. #4
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Much less so than a full page refresh for 300 users every 10 seconds.
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  5. #5
    Non-Member
    Join Date
    Oct 2009
    Posts
    1,852
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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. #6
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    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.
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  7. #7
    SitePoint Guru
    Join Date
    Sep 2007
    Posts
    971
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    can someone please supply me with a base ajax code?
    Animated Chatrooms - www.121chatrooms.net

  8. #8
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    If you're using a JS framework, many provide an example. Check out jQuery or MooTools et al.
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  9. #9
    SitePoint Wizard PHPycho's Avatar
    Join Date
    Dec 2005
    Posts
    1,201
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    A very good go for ajax click here

  10. #10
    Floridiot joebert's Avatar
    Join Date
    Mar 2004
    Location
    Kenneth City, FL
    Posts
    823
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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. #11
    SitePoint Enthusiast Sven S.'s Avatar
    Join Date
    May 2005
    Location
    Hamburg, Germany
    Posts
    53
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    As joebert said: Browser-based chat just sucks, sorry.

  12. #12
    SitePoint Wizard frank1's Avatar
    Join Date
    Oct 2005
    Posts
    1,392
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •