SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Sep 2006
    Location
    Oceanside, CA
    Posts
    0
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Hello, new guy here with question.

    I have a chat application. I am using java and ajax to send chat messages back and forth. Here is the problem.

    Say you send a message, and it takes a while to get there.

    1. Should the system wait until the message is received before letting you type a new one?

    2. Should it send it regardless?

    or optimially

    3. Could it send it, let you continue writing, and then somehow notify you if the message is delayed.

    Now We have currently option 2 in place... so the question is, how CONCEPTUALLY could you achieve option three in JavaScript using ajax.

    Any thoughts on the matter would be appreciated.

    Nick

    btw, if you want to see what i am talking about, the site is www.chatstat.com

  2. #2
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    i think you're talking about JAVA, not JavaScript.

    completly different.
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  3. #3
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    1. Should the system wait until the message is received before letting you type a new one?
    If the order of the lines of text that a user types are important - then yes. Otherwise you might find yourself in this situation:

    - user types - HELLO BOB - this gets sent to the server but it's delayed (it does get there eventually)
    - user types - ARE YOU THERE? - this gets sent to the server but it's NOT delayed

    Bob sees:
    ARE YOU THERE?
    HELLO BOB

    What you could do is
    - keep track of whether the httprequest has finished successfully
    - if the user types some more text before it's complete, store it somewhere, and then send it off when the first request completes.
    - make each httprequest capable of sending multiple lines of text, so you don't get backlogged
    - add a timeout so that if a httprequest doesn't finish successfully in X seconds, it notifies the user


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
  •