Not logged in. · Lost password · Register
Forum: XMPP Protocol RSS
Avatar
ayyrk #1
Member since Jul 2007 · 92 posts
Group memberships: Members
Show profile · Link to this post
Subject: Login and Presence
Hello,

I'd like to reduce network traffic by not re-downloading my roster every time OnLogin is called.

Currently I SendMyPresence in the OnLogin callback. I believe that triggers the server to send me my roster.

On these power saving WM5 devices the socket is periodically closed. I automatically reconnect and re-download the roster.

The general question is: What is the most network-traffic-conserving way to keep the roster up to date?


Thanks!!
Avatar
Alex #2
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
no you are wrong.
The Roster will be requested automaticlly from the SDK when AutoRoster of XmppClientConnection is true.
If you set it to false it will not be requested automatically. You can cache the roster and sync it manual from time to time.

Alex
Avatar
kevin #3
User title: kevin
Member since Dec 2007 · 13 posts · Location: chengdu.china
Group memberships: Members
Show profile · Link to this post
how can I get the roster and this prensence of roster when I set the AutoRoster false?
Avatar
Alex #4
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
you get the presence of your contacts after sending your own presence to the server. It does not matter if you requested your own roster or not.

To request the roster use the RequestRoster function of XmppClientConnection or the following code directly in your application.
  1. public void RequestRoster()
  2. {      
  3.     RosterIq iq = new RosterIq(IqType.get);
  4.     xmppCon.IqGrabber.Send(iq, new IqCB(OnRosterIQ), null);
  5. }
  6.  
  7. private void OnRosterIQ(IQ iq)
  8. {          
  9.     Roster r = iq.Query as Roster;
  10.     if (r != null)
  11.     {
  12.         foreach (RosterItem i in r.GetRoster())
  13.         {
  14.             // loop contacts
  15.         }
  16.     }
  17. }

Alex
Avatar
kevin #5
User title: kevin
Member since Dec 2007 · 13 posts · Location: chengdu.china
Group memberships: Members
Show profile · Link to this post
Alex,thank you.
Avatar
mrbelk #6
Member since Feb 2017 · 23 posts
Group memberships: Members
Show profile · Link to this post
Resurrecting a very old thread here...

I am trying to re-refetch the roster and send my presence in the OnRosterEnd event to refresh the presence info of my roster, but it's not happening (inasmuch as my PresenceFilter is not getting triggered when I set a breakpoint in it).

Any suggestions?

-MrB
Avatar
Alex #7
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
  • how are you sending your presence?
  • Do you have a XML log?
Avatar
mrbelk #8
Member since Feb 2017 · 23 posts
Group memberships: Members
Show profile · Link to this post
I don't have an XML log, but I will get one.

I am sending my presence with a call like this:
client.SendPresence(Show.Chat, "ONLINE");

-MrB
Avatar
mrbelk #9
Member since Feb 2017 · 23 posts
Group memberships: Members
Show profile · Link to this post
In reply to post #7
Alex,

Here is a copy of the android logcat output with the XMPP messages _after_ I call the "RequestRoster" and "SendPresence". I call the SendPresence from the OnRosterEnd event handler.

03-03 09:05:45.515: D/PUP.NST(4251): SEND: <iq id="MX_3" type="get" xmlns="jabber:client">
03-03 09:05:45.515: D/PUP.NST(4251):   <query xmlns="jabber:iq:roster" />
03-03 09:05:45.515: D/PUP.NST(4251): </iq>
03-03 09:05:45.518: D/PUP.NST(4251): SEND: <presence xmlns="jabber:client">
03-03 09:05:45.518: D/PUP.NST(4251):   <show>chat</show>
03-03 09:05:45.518: D/PUP.NST(4251):   <status>ONLINE</status>
03-03 09:05:45.518: D/PUP.NST(4251):   <priority>0</priority>
03-03 09:05:45.518: D/PUP.NST(4251): </presence>
03-03 09:05:45.525: D/PUP.NST(4251): RECV: <iq type="result" id="MX_3" to="1703011443@webtest.bizspeed.corp/NURSE" xmlns="jabber:client">
03-03 09:05:45.525: D/PUP.NST(4251):   <query xmlns="jabber:iq:roster">
03-03 09:05:45.525: D/PUP.NST(4251):     <item jid="plsadmin@webtest.bizspeed.corp" name="PLS Admin" subscription="both">
03-03 09:05:45.525: D/PUP.NST(4251):       <group>1_1_CCU</group>
03-03 09:05:45.525: D/PUP.NST(4251):     </item>
03-03 09:05:45.525: D/PUP.NST(4251):     <item jid="1702240949@webtest.bizspeed.corp" name="1702240949" subscription="both">
03-03 09:05:45.525: D/PUP.NST(4251):       <group>1_1_CCU</group>
03-03 09:05:45.525: D/PUP.NST(4251):     </item>
03-03 09:05:45.525: D/PUP.NST(4251):     <item jid="1_ccu_100_1@webtest.bizspeed.corp" name="1_ccu_100_1" subscription="both">
03-03 09:05:45.525: D/PUP.NST(4251):       <group>1_1_CCU</group>
03-03 09:05:45.525: D/PUP.NST(4251):     </item>
03-03 09:05:45.525: D/PUP.NST(4251):   </query>
03-03 09:05:45.525: D/PUP.NST(4251): </iq>
03-03 09:05:45.543: D/PUP.NST(4251): SEND: <presence xmlns="jabber:client">
03-03 09:05:45.543: D/PUP.NST(4251):   <show>chat</show>
03-03 09:05:45.543: D/PUP.NST(4251):   <status>ONLINE</status>
03-03 09:05:45.543: D/PUP.NST(4251):   <priority>0</priority>
03-03 09:05:45.543: D/PUP.NST(4251): </presence>
03-03 09:05:45.553: D/PUP.NST(4251): RECV: <presence from="1703011443@webtest.bizspeed.corp/NURSE" to="1703011443@webtest.bizspeed.corp/NURSE" xmlns="jabber:client">
03-03 09:05:45.553: D/PUP.NST(4251):   <show>chat</show>
03-03 09:05:45.553: D/PUP.NST(4251):   <status>ONLINE</status>
03-03 09:05:45.553: D/PUP.NST(4251):   <priority>0</priority>
03-03 09:05:45.553: D/PUP.NST(4251): </presence>
03-03 09:05:45.650: D/PUP.NST(4251): RECV: <presence from="1703011443@webtest.bizspeed.corp/NURSE" to="1703011443@webtest.bizspeed.corp/NURSE" xmlns="jabber:client">
03-03 09:05:45.650: D/PUP.NST(4251):   <show>chat</show>
03-03 09:05:45.650: D/PUP.NST(4251):   <status>ONLINE</status>
03-03 09:05:45.650: D/PUP.NST(4251):   <priority>0</priority>
03-03 09:05:45.650: D/PUP.NST(4251): </presence>
03-03 09:07:02.494: D/PUP.NST(4251): SEND:
Avatar
Alex #10
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
According to your log its called before the roster was received.

Why are you doing it manual?  When AutoPresence is true then MatriX takes care of it. Just set the desired Status and ShowType before you login.

Alex
Avatar
mrbelk #11
Member since Feb 2017 · 23 posts
Group memberships: Members
Show profile · Link to this post
I saw that. I was mistakenly calling the "SendPresence" immediately after "RequestRoster" and then calling it again in OnRosterEnd. I do have the "AutoPresence" set to true, as well as "AutoRoster".

I might just refactor my app to keep my roster list in a more permanent scope.
Avatar
Alex #12
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
I suggest to let MatriX handle it. Just set AutoRoster and AutoPresence to true.
If anything is changing in your roster you always get the OnRosterItem event in realtime.

If you want to change our presence information after the login just update the presence related properties and call a SendPresence()

Alex
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters: