Not logged in. · Lost password · Register
Forum: agsXMPP SDK Support RSS
Avatar
hexin #1
User title: to search knowledge
Member since Mar 2007 · 34 posts · Location: China
Group memberships: Members
Show profile · Link to this post
Subject: self define iq problem
The corporate total have 8 thousands users.In my implementation, when one user login, I only load users in his sub organization.If he want to view the state of user in other organization. The programme sends self-defined iq to query the user state, the self-defined iq class is as follow:

namespace Library.ProtocolEx
{
    public class UserInfoIq : IQ
    {
        private UserInfo m_UserInfo = new UserInfo();
        public UserInfoIq()
        {         
            base.Query = m_UserInfo;
            this.GenerateId();
        }
        public UserInfoIq(IqType type)
            : this()
        {
            this.Type = type;
        }
        public UserInfoIq(IqType type, Jid to)
            : this(type)
        {
            this.To = to;
        }
        public UserInfoIq(IqType type, Jid to, Jid from)
            : this(type, to)
        {
            this.From = from;
        }
        public new UserInfo Query
        {
            get
            {
                return m_UserInfo;
            }
        }
     
    }
    public class UserInfo : Element
    {
        public UserInfo()
        {
            this.TagName = "query";
            this.Namespace = "Library.ProtocolEx";
        }
        public string Name
        {
            get { return GetTag("Name"); }
            set { SetTag("Name", value); }
        }
        public string OrgId
        {
            get { return GetTag("OrgId"); }
            set { SetTag("OrgId", value); }
        }
        public int State
        {
            get { return GetTagInt("State"); }
            set { SetTag("State", value.ToString()); }
        }
    }
}

And I register it in the factory:
AddElementType("query", "Library.ProtocolEx", typeof(Library.ProtocolEx.UserInfo));



When one user want to view the state of rosters whom are in other organization,The programme will send the following query iq to everyone in this organization:
 
 UserInfoIq iq = new UserInfoIq(IqType.get, new Jid(rInfo.Jid + "/agsXMPP"));
 XmppCon.IqGrabber.SendIq(iq, new IqCB(GetUserState), null);     

 

If the user whom I query is online,he will receive the iq,and send the response iq. The dealt process is as follow:
        private void HandleQueryIq(IQ iq,Element query)
        {
            Type t = query.GetType();
            if (t == typeof(UserInfo))
            {
                UserInfo info = query as UserInfo;
                if (iq.Type == IqType.get)
                {
                    iq.SwitchDirection();
                    iq.Type = IqType.result;
                    info.Name = XmppCon.PersonName;
                    info.OrgId = mMyOrgInfo.Substring(0, mMyOrgInfo.IndexOf("-"));
                    info.State = Convert.ToInt32(XmppCon.Show);
                    XmppCon.Send(iq);
                }
            }
        }


The problem is when I send query iq,if there are some rosters whom I query is online. The programme often exits on exception in function EndReceive(IAsyncResult ar)' of ClientSocket class and throw out "broken uncompressed block" exception or sometimes, the client can only send message but can't receive message.

I think it's the fault of self-defined  response iq,but I can't figure out the problem.
This post was edited on 2008-05-20, 03:34 by hexin.
Avatar
Jabberer #2
Member since Feb 2006 · 249 posts
Group memberships: Members
Show profile · Link to this post
Quote by hexin:
in your constructor you have:

  1. public UserInfo()
  2. {
  3.    this.TagName = "query";
  4.    this.Namespace = "Sysd.CrecFim.Library.ProtocolEx";
  5. }


so you also have to register the same namespace
instead of:

  1. AddElementType("query", "Library.ProtocolEx", typeof(Library.ProtocolEx.UserInfo));
you have to register:
  1. AddElementType("query", "Sysd.CrecFim.Library.ProtocolEx", typeof(Library.ProtocolEx.UserInfo));

this are XML namespaces, they are not related to all to .NET namespaces in your source.

Quote by hexin:
I think it's the fault of self-defined  response iq,but I can't figure out the problem.

no, except of the namespace above your code is correct, and it works. Looks to me like its exactly the same problem as we have discussed in this thread:
http://forum.ag-software.de/forum.php?req=thread&id=565
Try to disable compression, it seems to be broken in some cases in Openfire. I don't think its an agsXMPP problem, because nobody reported such a problem yet with other servers.
Software Developer
AG-Software
Avatar
hexin #3
User title: to search knowledge
Member since Mar 2007 · 34 posts · Location: China
Group memberships: Members
Show profile · Link to this post
Thanks for your help! As you said, when I set 'XmppCon.UseCompression = false;',I test for many times,the phenomena I described above doesn't happen again. But if we don't compress the stream, it will be very slow for logining or get vcard. If there is any way to solve this problem? Does we have to resort to openfire developer to solve this problem?
Avatar
Jabberer #4
Member since Feb 2006 · 249 posts
Group memberships: Members
Show profile · Link to this post
Quote by hexin:
If there is any way to solve this problem? Does we have to resort to openfire developer to solve this problem?
yes, we have not seen this problem in any of our own projects, but we don't use Openfire on the server side. Also no other users reported such a problem yet. So I think its an Openfire problem. You can try to debug asgXMPP and locate the problem, or contact the Openfire support.
Software Developer
AG-Software
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:
Forum: agsXMPP SDK Support RSS