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.
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, 02:34 by hexin.