[JDEV] Proper use of Perl Net::Jabber calls

Yanming Xiao xiao at legatovideo.com
Tue Jan 7 11:02:46 CST 2003


Rabbaj,

It seems to me that you are using 2 different packages.  

There is a function called "RosterGet()" in Net::Jabber::Client. 
find the sample code in:
http://jru.jabberstudio.org/


-Yanming
  ----- Original Message ----- 
  From: rebbaj rebbaj 
  To: jdev at jabber.org 
  Sent: Tuesday, January 07, 2003 9:40 AM
  Subject: [JDEV] Proper use of Perl Net::Jabber calls


  Hello jabber people.

  I am hoping that someone can help me out with how the Perl Net::Jabber library should be used.  Note that I am also somewhat new to perl so if I get confused by some of the syntax, you will have to excuse me.  The examples in the Oreily book were rather helpful but I seem to be having problems in calling and receiving IQ information.

  Here is what I am trying to send and receive in XML:

  SENT:
  <iq id="jcl_9" type="get">
      <query xmlns="jabber:iq:roster"/>
  </iq>

  RECV:
  <iq from='rebbaj at jabber.org/Perl' id='jcl_9' type='result'>
    <query xmlns='jabber:iq:roster'>
      <item jid='rebbaj at jabber.com' name='rebbaj' subscription='both'/>
      <item jid='rebbaj2 at jabber.com' name='rebbaj2' subscription='both'/>
    </query>
  </iq>

  The code stub that I have written to do this is as follows.  I suspect that I have the flow a bit wrong and I am not using the optimal calls to parse the resulting returned roster data...  Any help would be appreciated....

  rebbaj

  ------------------------------------------------
  #!/usr/bin/perl
  use Net::Jabber qw(Client);
  use strict;
  my $c=Net::Jabber::Client->new();
  $c->Connect('hostname'=> 'jabber.org', 'port'=>5222);

  $c->AuthSend('username'=> 'rebbaj',
        'password'=> 'secret',
        'resource'=> 'Perl');

  $c->SetCallBacks('presence'=> \&handle_presence);
  $c->SetCallBacks('iq'=> \&handle_iq);
  $c->PresenceSend();

  My $IQ = new Net::Jabber::IQ();
  $IQ->NewQuery("jabber:iq:roster");  # Does this actually make the IQ get request?$c->Send($IQ); # is this call necessary?

  print "involking process\n";
  $c->Process();






  $c->Disconnect;
  exit(0);

  sub handle_presence {
   my ($sid, $presence) = @_;

   my $show = $presence->GetShow() || 'online';
   
   print "presence packet received $show\n";
  }

  sub handle_iq {
   my ($sid, $iq) = @_;

   my $querytag = $iq->GetQuery();


   print "iq packet received $querytag\n";
  }






------------------------------------------------------------------------------
  With Yahoo! Mail you can get a bigger mailbox -- choose a size that fits your needs
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.jabber.org/pipermail/jdev/attachments/20030107/64f5f449/attachment-0002.htm>


More information about the JDev mailing list