I want to know what is exactly AJAX heartbeat pattern and what is the difference between it and jquery setInterval
Because im making an AJAX chat and I don't want to pull the data every 15 seconds I want to make a connection to the server to avoid delay is that what called heartbeat ? Also I want a good tutorial to make this or any suggestion from you
Note: I have pleted the implementation with setInterval but I saw that heartbeat is better way to avoid delay
I want to know what is exactly AJAX heartbeat pattern and what is the difference between it and jquery setInterval
Because im making an AJAX chat and I don't want to pull the data every 15 seconds I want to make a connection to the server to avoid delay is that what called heartbeat ? Also I want a good tutorial to make this or any suggestion from you
Note: I have pleted the implementation with setInterval but I saw that heartbeat is better way to avoid delay
Share Improve this question edited Nov 14, 2011 at 13:54 Smamatti 3,9313 gold badges33 silver badges44 bronze badges asked Nov 14, 2011 at 13:31 SederSeder 2,7632 gold badges24 silver badges43 bronze badges 3- Afaik this is a design pattern and not a function. You keep sending requests to the server, so the server knows the user/browser is still present. - First hits on google... – Smamatti Commented Nov 14, 2011 at 13:38
- In my question in the first line i asked what is AJAX heartbeat pattern and i said its pattern I am hitting google since two days and I came here because here i can see experts that already done this before and can give me the concept better not punishing me for my question anyway thank you for your help I will appreciate reading the question first and consider that I will not ask here until i am out of solutions – Seder Commented Nov 14, 2011 at 13:43
- It's a deisgn pattern and not a function. You knew that, ok. I downvoted this question, because I don't see the research effort in it since the first result on google explain the pattern. - I may decided to harsh. Fixed it. Please state the next time your research effort more clear. – Smamatti Commented Nov 14, 2011 at 13:55
1 Answer
Reset to default 7Heartbeat is a design pattern, this means it's a way of coding solutions.
Here a technique is meant, where you keep sending requests to the server, so the server knows the user/browser is still present. There are several use-cases for this pattern, for example to prevent timeouts of sessions etc.
You cannot really pare a design pattern to a function, because setInterval
could be used to implement this pattern. You would keep sending request in a specified interval.
I don't have a tutorial at hand, but the first hits on google already contain some examples.