Q695 Posted September 2, 2014 Share Posted September 2, 2014 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. Quote Link to comment https://forums.phpfreaks.com/topic/290804-what-do-i-need-to-do-to-build-a-jquery-chat-object/ Share on other sites More sharing options...
kicken Posted September 2, 2014 Share Posted September 2, 2014 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. 1 Quote Link to comment https://forums.phpfreaks.com/topic/290804-what-do-i-need-to-do-to-build-a-jquery-chat-object/#findComment-1489656 Share on other sites More sharing options...
Q695 Posted September 3, 2014 Author Share Posted September 3, 2014 (edited) Aww, long polling to use it as a listener, unless they just join the chat 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 September 3, 2014 by Q695 Quote Link to comment https://forums.phpfreaks.com/topic/290804-what-do-i-need-to-do-to-build-a-jquery-chat-object/#findComment-1489705 Share on other sites More sharing options...
CroNiX Posted September 3, 2014 Share Posted September 3, 2014 Server side javascript? Are you using node.js or something? Quote Link to comment https://forums.phpfreaks.com/topic/290804-what-do-i-need-to-do-to-build-a-jquery-chat-object/#findComment-1489711 Share on other sites More sharing options...
Q695 Posted September 4, 2014 Author Share Posted September 4, 2014 (edited) You tell me what I'm going to use, because there's no good tutorial out there that I can find for some reason. Edited September 4, 2014 by Q695 Quote Link to comment https://forums.phpfreaks.com/topic/290804-what-do-i-need-to-do-to-build-a-jquery-chat-object/#findComment-1489848 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.