Not logged in. · Lost password · Register
Forum: agsXMPP RSS
Avatar
irokhes #1
Member since Mar 2012 · 16 posts
Group memberships: Members
Show profile · Link to this post
Subject: Execute commands
Hi,

how can i use commands? is there any sample to see how it works?

Thanks.
Avatar
Alex #2
Member since Feb 2003 · 4297 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Quote by irokhes:
how can i use commands? is there any sample to see how it works?

sorry, but there is no example. You have to study XEP-0050: Ad-Hoc Commands and its references. Then study and use the classes from the agsXMPP.protocol.extensions.commands namespace. If you have to build a Ui for the commands the agsXMPP.ui project will help you.
Avatar
irokhes #3
Member since Mar 2012 · 16 posts
Group memberships: Members
Show profile · Link to this post
I´m trying to compese this IQ stanza

<iq from='bard@shakespeare.lit/globe'
    id='add-user-1'
    to='shakespeare.lit'
    type='set'
    xml:lang='en'>
  <command xmlns='http://jabber.org/protocol/commands'
           action='execute'
           node='http://jabber.org/protocol/admin#add-user'/>
</iq>

I know how to compose a last iq because LastIq is a agsXmpp class, but I don´t know how to compose generic command. How do i compose this kind of messages??

Sorry but i´am newby in this area and need solve this problem.

Thank you so much!!
This post was edited on 2012-03-27, 13:30 by irokhes.
Avatar
Alex #4
Member since Feb 2003 · 4297 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
  1. var iq = new IQ
  2.    {
  3.       Type = IqType.set
  4.    };
  5. var command = new agsXMPP.protocol.extensions.commands.Command
  6.    {
  7.       Node = "http://jabber.org/protocol/admin#add-user",
  8.       Action = agsXMPP.protocol.extensions.commands.Action.execute
  9.    };
  10. iq.AddChild(command);
Avatar
irokhes #5
Member since Mar 2012 · 16 posts
Group memberships: Members
Show profile · Link to this post
Hi,

this is the flow to execute Get User Last Login Time:

 <iq id="prueba" type="set" to="servername">
<command xmlns="http://jabber.org/protocol/commands"
node="http://jabber.org/protocol/admin#get-user-lastlogin" action="execute" />
</iq>

Server response:

<iq xmlns="jabber:client" to="adminUser" id="prueba" type="result" from="servername">
<command xmlns="http://jabber.org/protocol/commands" sessionid="2012-03-27T17:58:17.873264Z" status="executing" node="http://jabber.org/protocol/admin#get-user-lastlogin">
<x xmlns="jabber:x:data"><field var="FORM_TYPE" type="hidden">
<value>http://jabber.org/protocol/admin</value>
</field>
<title>Get User Last Login Time</title>
<field label="Jabber ID" type="jid-single" var="accountjid"><required /></field>
</x>
</command>
</iq>

Admin request:

<iq id="prueba2" type="set" to="servername" from="adminuser"><command xmlns="http://jabber.org/protocol/commands" node="http://jabber.org/protocol/admin#get-user-lastlogin" sessionid="2012-03-27T17:58:17.873264Z"><x xmlns="jabber:x:data" type="submit"><field type="hidden" var="FORM_TYPE"><value>http://jabber.org/protocol/admin</value></field><field var="accountjids"><value>user3@servername</value></field></x></command></iq>


Server response:

<iq xmlns="jabber:client" to="adminuser" id="prueba" type="result" from="qprocxmpp">
<command xmlns="http://jabber.org/protocol/commands" sessionid="2012-03-27T17:58:17.873264Z" status="executing" node="http://jabber.org/protocol/admin#get-user-lastlogin">
<x xmlns="jabber:x:data"><field var="FORM_TYPE" type="hidden">
<value>http://jabber.org/protocol/admin</value></field><title>Get User Last Login Time</title><field label="Jabber ID" type="jid-single" var="accountjid"><required /></field></x></command></iq>

<iq xmlns="jabber:client" to="adminuser" id="prueba2" type="error" from="servername">
<command xmlns="http://jabber.org/protocol/commands" node="http://jabber.org/protocol/admin#get-user-lastlogin" sessionid="2012-03-27T17:58:17.873264Z">
<x xmlns="jabber:x:data" type="submit">
<field var="FORM_TYPE" type="hidden">
<value>http://jabber.org/protocol/admin</value>
</field>
<field var="accountjids"><value>user3@servername</value>
</field>
</x>
</command><error type="modify" code="400"><bad-request xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" /></error>
</iq>

I know 400 error means bad request but i can´t see where is the error.

thanks!!
Avatar
Alex #6
Member since Feb 2003 · 4297 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
you have a type in one of the fields. The rest looks correct.
You use var="accountjids" instead of var="accountjid"
Avatar
irokhes #7
Member since Mar 2012 · 16 posts
Group memberships: Members
Show profile · Link to this post
Thank you so much!!

;-)
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