AJAX chatroom, how to???

L

lihao0129

Hi, friends,

I am hoping to write a chatroom with the AJAX methodology. I knew I
can set periodic refreshment from the client-side code and make the
input from any visitor get updated to all others. But I think this
method is very low efficient since I have to contact the server in a
very short time interval.. Is there any more practical ways to do this
with AJAX?

Many thanks for your suggestions and time..

Regards,
lihao(XC)
 
V

VK

Hi, friends,

I am hoping to write a chatroom with the AJAX methodology. I knew I
can set periodic refreshment from the client-side code and make the
input from any visitor get updated to all others. But I think this
method is very low efficient since I have to contact the server in a
very short time interval.. Is there any more practical ways to do this
with AJAX?

XHR support HEAD, GET and POST request.

Shall your XHR use GET or POST to submit user input to the server and
to update the client-side chat as well.

Shall it send HEAD request every 1sec on setTimeout while idle (no
user submission) with properly set If-Modified-Since and other
relevant HTTP headers.

Shall the server-side script threats properly HEAD request and returns
proper meta data (yes no data / no new data)

Shall your client-side script reads properly meta data received and
either wait for another second or issues GET/POST request immediately.

Another option is to use Comet-like hacks, but I hate this too much to
discuss, so just giving you an info resource:
http://en.wikipedia.org/wiki/Comet_(programming)
 
T

Thomas 'PointedEars' Lahn

Joost said:
Now you've gone and made me curious.

Comet technology, which is not a hack (in the bad sense) at all, has been
discussed here recently.


PointedEars
 
J

Joost Diepenmaat

Thomas 'PointedEars' Lahn said:
Comet technology, which is not a hack (in the bad sense) at all, has been
discussed here recently.

/browses...

No-one's recently brought up any real-world problems with it, then?

Joost.
 
T

Thomas 'PointedEars' Lahn

Joost said:
/browses...

No-one's recently brought up any real-world problems with it, then?

As with all technology, Comet technology has both benefits and drawbacks,
which makes it suitable in one environment and unsuitable in another. These
things have been discussed here as well. STFW.


PointedEars
 
L

lihao0129

Hi, guys:

Thanks all for your helpful responses. I've read the book
"Professional AJAX edition-2" this afternoon, and think the Comet and
HTTP streaming is what I need to try. :)

XHR support HEAD, GET and POST request.
Shall your XHR use GET or POST to submit user input to the server and
to update the client-side chat as well.

I have no expreience with HEAD on an AJAX call, not sure if that
helps. but basically I think I will use a 'POST'.
Shall it send HEAD request every 1sec on setTimeout while idle (no
user submission) with properly set If-Modified-Since and other
relevant HTTP headers.

I thought of using setTimeout to do this, but as you mentioned it's
waste of resources when the activities are low or when users are
idle. :-( All no-cache HTTP headers, including Cache-Control, Pragma,
Last-Modified, Expires, have been taken care from my server-side code)

Shall the server-side script threats properly HEAD request and returns
proper meta data (yes no data / no new data)
Shall your client-side script reads properly meta data received and
either wait for another second or issues GET/POST request immediately.

I just need a model to update client-side content only when change
from other sides is made. and I think Comet(HTTP streaming)'s push
architecture is what I was looking for..
Another option is to use Comet-like hacks, but I hate this too much to
discuss, so just giving you an info resource:http://en.wikipedia.org/wiki/Comet_(programming)

really appreciate your helpful suggestions and the link: -)

Best,
lihao(XC)
 
V

VK

/browses...

No-one's recently brought up any real-world problems with it, then?

Comet is _terrible_ problem of the Web. It is more terrible because
99.9% of users (including the original technology promoters) having no
clue what are they doing with the way the WWW works.

RFC 2068
8.1.4 Practical Considerations
Clients that use persistent connections SHOULD limit the number of
simultaneous connections that they maintain to a given server. A
single-user client SHOULD maintain AT MOST 2 connections with any
server or proxy. A proxy SHOULD use up to 2*N connections to another
server or proxy, where N is the number of simultaneously active
users. These guidelines are intended to improve HTTP response times
and avoid congestion of the Internet or other networks.

Of course SHOULD is not MUST, but all major players do obey core RFCs

http://developer.mozilla.org/en/doc...er_Of_Simultaneous_xmlHttpRequest_Connections
http://support.microsoft.com/kb/282402

As the result we are having many HTTP channels cluttered in unexpected
way and - of course - "weird" client-side problems like the one I'm
answering right now at
http://groups.google.com/group/mozilla.dev.tech.javascript/browse_frm/thread/f1d00e400f23cdfe

Yes, I know exactly where his problem is so it would be enough to post
the mozilla.org link. But he is doing two things at once where each
one more and more terrible and dishonest: 1) he is doing Web-chat and
that one I would just smile over but tolerate and 2) he is doing Web-
chat with Comet. For that he must be punished by sueding out the
solution. Comet makes me feel like to be an a**hole.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top