Not logged in. · Lost password · Register
Forum: MatriX and XmppDotNet RSS
Avatar
yagami #1
Member since Mar 2012 · 30 posts
Group memberships: Members
Show profile · Link to this post
Subject: Get vCard will affect the UI
I use this code to get vcard
  1. VcardIq viq = new VcardIq { To = JID, Type = IqType.get };
  2. GlobalData.m_XmppClient.IqFilter.SendIq(viq, vcardResponse)
and vardResponse
  1. private void vcardResponse(object sender, IqEventArgs e)
  2. {
  3.  if (e.Iq.Type == IqType.result)
  4.  {
  5.      blahblahblah...
  6.  }
  7. }
And then, when I ask a lot of vcard, that made my App become very slow!After pass through vcardResponse, App become normal...
At First, I think maybe handle the vcard make it slow,but I
comment this
  1.  if (e.Iq.Type == IqType.result)
  2.  {
  3.      blahblahblah...
  4.  }
The App is still slow.....Why?And how to fix it?
Thanks a lot!
Avatar
Alex #2
Member since Feb 2003 · 4447 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Quote by yagami:
And then, when I ask a lot of vcard, that made my App become very slow!After pass through vcardResponse, App become normal...
Vcards can contain lots of data especially when there are avatars. When you request lots of vcards at the same time then MatriX hat lots of work to do. So its normal that your app will become slower.

1) You should cache vcards and not request the vcards of all your contacts each on login. Because vcards don't change this often.
2) You should not send out that many requests at the same time. When you have to request eg. 100 vcards then put all 100 Jids in a queue. Then send out the first request from your queue. When you get the response callback check if the queue is not empty and request the next one. This logic works also fine in background tasks and also multiple simultaneous requests and your app is still responding.

Alex
This post was edited on 2012-07-11, 12:49 by Alex.
Avatar
yagami #3
Member since Mar 2012 · 30 posts
Group memberships: Members
Show profile · Link to this post
ohhhhhhh....I got it!!
Thank you!!!!!:D
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: