Not logged in. · Lost password · Register
Forum: agsXMPP RSS
Is it even possible?
Page:  1  2  next
Avatar
Ingvarr #1
Member since Jun 2009 · 9 posts
Group memberships: Members
Show profile · Link to this post
Subject: Event AFTER message has been sent
Hello everyone
I've spent last few days trying to solve this problem. I'm writing an app, that will send many large messages. Problem is, that send() method (as I think) works asynchroniously, so I can't detect the moment when message is out. Does anyone knows how could I do this?
Avatar
Alex #2
Member since Feb 2003 · 4297 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
There are different solutions to achieve this.

1) Add an event handler to the asynchronus send in agsXMPP
2) Use an existing XMPP extension which acknowledges the message on the receiver side
3) Use IQs instead of messages which have always a response.

If you send all the messages to the same entity then IQs are probably a better solution then messages. Even if you add a callback to the async Send, you don't know how fast the other entity can process the incoming messages. With IQs you know and you are sure that you don't flood other entities with too many data.

Alex
Avatar
Ingvarr #3
Member since Jun 2009 · 9 posts
Group memberships: Members
Show profile · Link to this post
Alex, thank you very much :)
I read some about IQ and you're right, IQs can be exactly what I need :) But I can't find any snippet doing this job... I know I can send IQs through IqGrabber.SendIq(IQ) but as I understand, I have to read that IQ on other end, and then send back some reply... Or is it done automatically?
Avatar
Alex #4
Member since Feb 2003 · 4297 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
yes, the receiver has to process the iq and send a response with the same packet id. This does not happen automatically.
As a reference you can look at the roster or vcard IQs.

Alex
Avatar
Ingvarr #5
Member since Jun 2009 · 9 posts
Group memberships: Members
Show profile · Link to this post
Thank you very very much for your help :) Right now I'm on vacation, but as soon as I get back, I'll do as you suggested :) Thank you once more ;)
Avatar
Ingvarr #6
Member since Jun 2009 · 9 posts
Group memberships: Members
Show profile · Link to this post
OK, I'm totally stuck... I get iq's on sender side with IqType.error, no matter what IqType I choose, and IQ's are not sent outside, or I'm not able to get them properly.

I do something like this:
xmpp.OnIq += new IqHandler(xmpp_OnIq);

void xmpp_OnIq(object sender, IQ iq)
        {
            if (iq.GetTag("JaFT") != null && iq.Type == IqType.get)
            {

                // some code goes here...

                iq.Type = IqType.result;
                iq.SwitchDirection();
                iq.Value = null;
                xmpp.IqGrabber.SendIq(iq, 0);
            }

        }

and on sender side...

IQ iq = new IQ(IqType.get);
 iq.Value = builder.ToString();
 iq.From = xmpp.MyJID;
 iq.To = to;
 iq.AddTag("JaFT", "1");
 iq.GenerateId();
 xmpp.IqGrabber.SendIq(iq);

What is wrong with this?
This post was edited on 2009-07-10, 20:16 by Ingvarr.
Avatar
Alex #7
Member since Feb 2003 · 4297 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
please post your outgoing Xml and the incoming error. Then we can see whats going wrong.

Alex
Avatar
Ingvarr #8
Member since Jun 2009 · 9 posts
Group memberships: Members
Show profile · Link to this post
You're right :) Here you have outgoing and incoming xml

  1. <iq xmlns="jabber:client" type="get" from="jaft@jabster.pl/agsXMPP" to="JaFT@jabster.pl" id="agsXMPP_5">0
  2. _kotek - Kopia.jpg
  3. 1/103
  4. /9j/4AAQSkZJRgABAQAAAQABAAD/2wA=
  5. <JaFT>1</JaFT></iq>
  6.  
  7.  
  8. <iq xmlns="jabber:client" from="JaFT@jabster.pl" to="jaft@jabster.pl/agsXMPP" type="error" xml:lang="en" id="agsXMPP_5">0
  9. _kotek - Kopia.jpg
  10. 1/103
  11. /9j/4AAQSkZJRgABAQAAAQABAAD/2wA=
  12. <JaFT>1</JaFT><error code="400" type="modify"><bad-request xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" /></error></iq>
This post was edited on 2009-07-10, 22:12 by Ingvarr.
Avatar
Alex #9
Member since Feb 2003 · 4297 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
you are sending to a bare jid.
IQs must be sent always to a full Jid.

You also should put your data in a custom tag and namespace. Not in the value of the Iq.

Alex
Avatar
Alex #10
Member since Feb 2003 · 4297 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
and do not set the from property. The server stamps all your messages automatically. There is no need to set From, and its impossible to spoof the From address in XMPP.
This post was edited on 2009-07-11, 23:31 by Alex.
Avatar
Ingvarr #11
Member since Jun 2009 · 9 posts
Group memberships: Members
Show profile · Link to this post
Right, I knew it, but when you have to solve strange error, that came out of nowhere, you try anything :P Looks like it is solved... I'm quite embarrased to trouble you this much, But I'm reealy grateful :)

Another issue - I can't find it anywhere. When I login, I can request rooster, but I don't get any Presence info. Is there any way to request it?
This post was edited on 2009-07-12, 22:55 by Ingvarr.
Avatar
Alex #12
Member since Feb 2003 · 4297 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
You have to send your own Presence after login. Set either AutoPresence to true which sends the presence automatically after the roster is received. Or send the presence manual with SendMyPresence when you have received the roster.
If you don't send the presence then you show as offline to you contacts and the server does not send presences to you.

Alex
Avatar
Ingvarr #13
Member since Jun 2009 · 9 posts
Group memberships: Members
Show profile · Link to this post
I tried that...
I have 2 people in rooster, and for some reason I recieve presence from myself, but none from those 2 others.

xmpp.AutoAgents = true;
xmpp.AutoPresence = true;
xmpp.AutoResolveConnectServer = true;
xmpp.AutoRoster = true;
xmpp.Open(usrJid.User, usrPassword, usrJid.Resource);

as you see, I turned everything on :P
This post was edited on 2009-07-12, 23:21 by Ingvarr.
Avatar
Alex #14
Member since Feb 2003 · 4297 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
then you are probably not subscribed to them and not allowed to see the presence.
Post the Xml or the RosterIq result.
Avatar
Ingvarr #15
Member since Jun 2009 · 9 posts
Group memberships: Members
Show profile · Link to this post
I do something like this:

void xmpp_OnPresence(object sender, Presence pres)
{
    if (pres.Type == PresenceType.subscribe)
        xmpp.PresenceManager.ApproveSubscriptionRequest(pres.From);
}

So they should be subscribed... this is one of IQ's I recieve after login:

<iq xmlns="jabber:client" from="jabster.pl" to="jaft@jabster.pl/Serwer" type="error" xml:lang="en" id="agsXMPP_3"><query xmlns="jabber:iq:agents" /><error code="501" type="cancel"><feature-not-implemented xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" /></error></iq>

and rooster items...

{<iq xmlns="jabber:client" from="jaft@jabster.pl" to="jaft@jabster.pl/Serwer" type="result" id="agsXMPP_4"><query xmlns="jabber:iq:roster"><item jid="xxx@jabster.pl" subscription="from" /><item jid="yyy@gmail.com" subscription="from" /></query></iq>}
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:
Page:  1  2  next
Forum: agsXMPP RSS