Not logged in. · Lost password · Register
Forum: agsXMPP RSS
Avatar
lizhengjun #1
Member since May 2011 · 3 posts
Group memberships: Members
Show profile · Link to this post
Subject: BUG: XmppClientConnection.Send(Element e)
  1.         public override void Send(Element e)
  2.         {
  3.             if (!(ClientSocket is BoshClientSocket))
  4.             {
  5.                 // this is a hack to not send the xmlns="jabber:client" with all packets
  6.                 Element dummyEl = new Element("a");
  7.                 dummyEl.Namespace = Uri.CLIENT;
  8.                 dummyEl.AddChild(e);
  9.                 string toSend = dummyEl.ToString();
  10.                 Send(toSend.Substring(25, toSend.Length - 25 - 4));
  11.             }
  12.             else
  13.                 base.Send(e);
  14.         }

It will cause offline exception if frequently send, should change to:

  1.         public override void Send(Element e)
  2.         {
  3.             if (!(ClientSocket is BoshClientSocket))
  4.             {
  5.                 if (string.IsNullOrEmpty(e.Namespace))
  6.                 {
  7.                     e.Namespace = Uri.CLIENT;
  8.                 }
  9.                 string data = e.ToString();
  10.                 Send(data);
  11.             }
  12.             else
  13.                 base.Send(e);
  14.         }
Avatar
Alex #2
Member since Feb 2003 · 4297 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
your code does the opposite of my code. I also don't see why there is a problem in the original code.
Please post your complete stacktrace when it crashes.

Alex
Avatar
lizhengjun #3
Member since May 2011 · 3 posts
Group memberships: Members
Show profile · Link to this post
Subject: m_NetworkStream.EndRead(ar)=0
when i use your code to send IQ frequently, the function

void EndReceive(IAsyncResult ar)

int nBytes;
nBytes = m_NetworkStream.EndRead(ar);

nBytes == 0,Then cause xmppconnection closed;

when use my code ,it not Occur?
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 RSS