Jump to content

What do I need to do to build a JQuery chat object?


Q695

Recommended Posts

I'm confused how to get the chat object to work with the pushes/pulls, and don't know where I'm going wrong.  Here's the basics of what I need to know without reloading the page:

how do I push new data to the server

how do I push new data to the client

how do I not rebuild the data client has every time

 

I may need to know more, but that's what I know I need to be able to do so far.

Link to comment
Share on other sites

If you want to go cutting edge, you could look into Websockets, optionally using something like Socket.IO for compatibility.

 

Otherwise you'd do standard AJAX requests to poll the data for new information as well as push new information to the server. When polling for new data you'd need to send some kind of indicator to let the server know what data you've already received, such as a timestamp of the last polling time.

 

As far as the polling goes you have two basic options:

  • Long poll - The server will block on the request until it has new data to send. This minimizes the number of requests and bandwidth needed but ties up the servers processing threads.
  • Short poll - The server will return quickly either with the new data or with nothing. A new polling request must be sent periodically. This increases the requests made and bandwidth used but keeps the server's processing threads open
With a little extra work you could go in between long and short and have a timeout. The server could wait for say 30 seconds for new data before returning an empty response. Your server resources would not be tied up long and you can save some bandwidth with fewer requests.
  • Like 1
Link to comment
Share on other sites

Aww, long polling to use it as a listener, unless they just join the chat :D

 

Is there a way to do long polling within jquery technology working with the data possibly changing every time?

 

What would I post for the server side JavaScript, and client side JavaScript?

Edited by Q695
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.