Resuming XMPP connection upon page refresh

╄→尐↘猪︶ㄣ 提交于 2019-12-23 04:55:49

问题


I am not able to maintain the connection on page refresh.

Initially upon every refresh Strophe connection object is lost. So, the first approach I took was reconnecting on refresh.

I am saving the JID, SID and RID in localStorage send the strophe attach call with saved details.

AuthHandler.attach_params(jid_frm_storage, sid_frm_storage, rid_frm_storage);

The attach callback is in actual AuthHandler Object that I have created and is logging perfectly that means it is okay to assume that my attach was successful but still I am not able to send or receive any messages

My second approach I saved the latest RID in locastorage and used it to attach as I came to know upon researching on already posted problems online that RID changes frequently. (Although please note I am saving RID only when either i send message or receive a message).

I also tried sending presence.

ConnectionHandler.connection.send($pres());

But no luck here either!

In my last approach I re-authorized, .i.e I connected and re-logged in and then sent the auth, still no luck.

How can I resume my connection upon refresh. What are the things That I need to do from Strophes end in order to reconnect and resume the same conversation.

NOTE: I am not that clear with how XMPP works internally but I have been able to push this far by learning-by-doing approach. I know it would be great to wait and learn a bit on xmpp before rushing forward but I can't afford that right now as we are prototyping fast.

Will really appreciate if steps required to accomplish this can be explained in detail.


回答1:


Solved this:

The best way to solve this is by saving the login credentials in localStorage (mind you it might not meet your security requirements, met mine though) and then make a proper connection again, but this time with same credentials as before.



来源:https://stackoverflow.com/questions/39763578/resuming-xmpp-connection-upon-page-refresh

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!