Not logged in. · Lost password · Register
Forum: agsXMPP RSS
Avatar
adrianporger #1
Member since Oct 2012 · 2 posts
Group memberships: Members
Show profile · Link to this post
Subject: How to receive the param collection in RPC IQ
Hi Alex,

the RPC Class has a property for the MethodCall name but how to access the ArrayList of Parameters?

For example on one client:
  1.      var jid1 = new agsXMPP.Jid("cid@adrian-pc");
  2.                       var iq = new agsXMPP.protocol.iq.rpc.RpcIq(IqType.set, jid1);
  3.                        var param = new ArrayList();
  4.                         param.Add("admin");
  5.                         param.Add("admin");
  6.                         iq.Query.MethodCall = new MethodCall("authenticate", param);
  7.    
  8.                        IQ result = xmppCon.IqGrabber.SendIq(iq, 5000);

on the receiver side:
  1. Private Sub xmpphost_OnIq(sender As Object, iq As agsXMPP.protocol.client.IQ) Handles xmpphost.OnIq
  2.  Dim query As Element = iq.Query
  3.  If query.GetType() Is GetType(agsXMPP.protocol.iq.rpc.Rpc) Then
  4.                 Dim rpc As agsXMPP.protocol.iq.rpc.Rpc = CType(query, agsXMPP.protocol.iq.rpc.Rpc)
  5.                 If iq.Type = IqType.set Then
  6.                     '// Somebody wants to know our client version, so send it back
  7.                     iq.SwitchDirection()
  8.                     iq.Type = IqType.result
  9.  
  10.                     Select Case rpc.MethodCall.MethodName
  11.  
  12.                         Case "authenticate"
  13.                             Dim mc As MethodCall = rpc.MethodCall
  14.                             Dim params = '? how to get the params in a typed way?
  15.                             ' Dim usr As String
  16.                     End Select[code]
  17.  
  18.                     xmpphost.Send(iq)
  19.                 End If
  20.             End If
  21. End Sub
This post was edited on 2012-10-12, 09:33 by Alex.
Avatar
Alex #2
Member since Feb 2003 · 4327 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
  1. ArrayList resp = rpcObj.MethodResponse.GetResponse();
Avatar
adrianporger #3
Member since Oct 2012 · 2 posts
Group memberships: Members
Show profile · Link to this post
Subject: ?
Hi Alex, sorry i think you missunderstand sorry for not beeing clear enough

again if client A sends the RPC IQ to client B

  1. var jid1 = new agsXMPP.Jid("cid@adrian-pc");
  2. var iq = new agsXMPP.protocol.iq.rpc.RpcIq(IqType.set, jid1);
  3. var param = new ArrayList();
  4. param.Add("admin");
  5. param.Add("admin");
  6. iq.Query.MethodCall = new MethodCall("authenticate", param);
  7.  
  8. IQ result = xmppCon.IqGrabber.SendIq(iq, 5000);


on Client B("cid@adrian-pc") the method response is empty as the response has to be created first from the invoked procedure right?

  1. Private Sub xmpphost_OnIq(sender As Object, iq As agsXMPP.protocol.client.IQ) Handles xmpphost.OnIq
  2. Dim query As Element = iq.Query
  3. If query.GetType() Is GetType(agsXMPP.protocol.iq.rpc.Rpc) Then
  4.    Dim rpc As agsXMPP.protocol.iq.rpc.Rpc = CType(query, agsXMPP.protocol.iq.rpc.Rpc)
  5.    If iq.Type = IqType.set Then
  6.       '// Somebody wants to know our client version, so send it back
  7.       iq.SwitchDirection()
  8.       iq.Type = IqType.result
  9.  
  10.       Select Case rpc.MethodCall.MethodName
  11.  
  12.          Case "authenticate"
  13.             Dim mc As MethodCall = rpc.MethodCall
  14.             Dim params = '? how to get the params in a typed way to read parameters
  15.             Dim  MR as MethodResponse = SomeService.Invoke(mc.MethodName, params)
  16.             rpc.MethodCall = nothing
  17.             rpc.MethodResponse = MR
  18.                            
  19.          End Select
  20.          xmpphost.Send(iq)
  21.       End If
  22.    End If
  23. End Sub

Now again on Client A i can use

ArrayList resp = rpcObj.MethodResponse.GetResponse();

to get the typed Response right?
This post was edited on 2012-10-13, 21:44 by Alex.
Avatar
Alex #4
Member since Feb 2003 · 4327 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
there wasn't such a methd yet, because most people were using other RPC libraries to write the xml of the response and just add it as a child. I have made some extensions. When you download the latest sources form SVN you will see a WriteResponse member now which should write the response for you. I have not tested the code, so please let me know if it works ;-)

Quote by adrianporger:
ArrayList resp = rpcObj.MethodResponse.GetResponse();

to get the typed Response right?

thats correct.

In you code I always see bare Jids, that wrong. IQs must be send always to full Jids when you send the from client to client. Otherwise the server will return an error to you.

Alex
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