chzn
chzn

Reputation: 35

Chat application issue while using long polling

Sup Dev´s.

I´m currently working on a chat application like facebook but using long polling. Everytime i open a chat window a long polling request will be sent to the server and restarts if the request times out or successfully responds. But if i close the window tab for a specific friend and open the window tab again two long polling requests are waiting for a new message on the server and responds both if there is one. so it returns 2 messages for each message send from the opponent and 2 messages will be displayed. what can i do so there wont be any more long polling requests for each friends chat window? Can i bind a function to interrupt the first long polling request with the chat windows close button? Any other ways to get my thing done?

Thanks Chzn.

Upvotes: 0

Views: 55

Answers (1)

chzn
chzn

Reputation: 35

works perfectly. using this...

if(!$("#"+result.chatid).length) { //do things }

...to check for existing messages.

Upvotes: 1

Related Questions