Not logged in. · Lost password · Register
Forum: agsXMPP SDK Support RSS
Avatar
jason #1
Member since Oct 2007 · 9 posts
Group memberships: Members
Show profile · Link to this post
Subject: RPC after connection init
I am trying to make an RPC soon after the connection has initialized, behind the scenes on app startup, before a form is rendered. I try to catch the connection completion by looking for

private void XmppConn_OnXmppConnectionStateChanged(object sender, XmppConnectionState state)
{
    if (XmppConn.XmppConnectionState == XmppConnectionState.SessionStarted)
            {
                // make rpc at this time
            }
}

It appears the connection may not be completed at this point, becuase the rpc takes a long time, specifically a long time to receive a response. If I create a button on my form and then click the button the RPC sends quickly and receives the response quickly. Is there something else I should be looking for or any reason for this behavior?
Avatar
Alex #2
Member since Feb 2003 · 4245 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Hello,

your code looks ok. Can you post your debug xml here (with timestamps whens possible)?

According to the RFC XMPP servers have to guarantee in order delivery. Which means if the library sends other packets before your RPC call they also be processed first. But we will see this in your log once you posted it.

Did you send your own presence to the server? If you don't send your own presence to the server you get no messages at all, and for some servers also no IQ's.

Alex
Alexander Gnauck
AG-Software
Avatar
jason #3
Member since Oct 2007 · 9 posts
Group memberships: Members
Show profile · Link to this post
My apologies, the issue is the following: After sending the rpc, I am polling a response queue for the response. The response queue is updated in the onIQ when a response comes in. I believe my issue is that I am on the same thread, thus while polling the onIQ isnt called. If I use the button approach I am now on the UI thread and thus the onIQ is called immediately when a response comes in (since on a separate thread). Does this logice make sense? If so any suggestions?

public static void sendTest()
        {
           
            string id = sendXmppRpc();

            ArrayList list = (ArrayList)checkForXmppResponse(id);

        }

private static object checkForXmppResponse(string id)
        {
            XmppClient xmppService = XmppClient.getInstance();

            DateTime pollEnd = DateTime.Now.AddMinutes(1);

            while (DateTime.Now.CompareTo(pollEnd) < 0)
            {
                if (xmppService.XmppRpcResponseQueue.ContainsKey(id))
                {
                    object response = xmppService.XmppRpcResponseQueue[id];
                    xmppService.XmppRpcResponseQueue.Remove(id);
                    return response;
                }
            }

private void XmppConn_OnIq(object sender, agsXMPP.Xml.Dom.Node e)
{
        if (iq.Type == IqType.result)
                            {
                                XmppRpcResponseQueue.Add(iq.Id, rpc.MethodResponse.GetResponse());
                            }
}
Avatar
Alex #4
Member since Feb 2003 · 4245 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
why are you polling and not using the IqGrabber with callbacks?
agsXMPP is using asynchronous network code. It also does not run in your UI tread,. There should be nothing in agsXMPP which could block your code.
Is in the checkForXmppResponse function your polling logic?

Alex
Alexander Gnauck
AG-Software
Avatar
jason #5
Member since Oct 2007 · 9 posts
Group memberships: Members
Show profile · Link to this post
I am doing this becuase of my ignorance of the IqGrabber. It is my custom function. I will look into the IqGrabber now. Do you have an example of how it is used?
Avatar
Alex #6
Member since Feb 2003 · 4245 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
There are some examples of the usage in the MiniClient. Look at the Disco or Vcard code.

Alex
Alexander Gnauck
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