[JDEV] Perl code sample needed...

rebbaj rebbaj rebbaj2000 at yahoo.co.uk
Mon Jan 27 01:40:22 CST 2003


Thanks Curtis,
I have not seen any referenced to the RosterParse in Jabber::Net 1.0028.  It only seems to show up in the 1.0024 documentation.  Is there a way to do this using 1.0028?
 Curtis Hawthorne <cghawthorne at yahoo.com> wrote:Rebbaj,

I think what you want is the RosterParse method in
Net::Jabber. It returns a hash with all the information
you need. For instance:

sub InIQ {
my $sid = shift;
my $iq = shift;

my %rosterupdate = $iq->RosterParse($iq);

foreach (keys %rosterupdate) {
print "Name: ", $_->{name}, "\n";
print "Subscription: ", $_->{subscription}, "\n";
print "Ask: ", $_->{ask}, "\n";
print "Groups: ", $_->{groups}, "\n";
}
}

>From there you could turn it into an array if you wanted,
but I would think a hash would be easier to work with.

Curtis H.

--- rebbaj rebbaj wrote:
> 
> After some more testing, I got the impression that the
> following callback logic would work. Getting the s
> does not seem to work. Has anybody ever made this work
> before?? 
> sub InIQ
> {
> my $sid = shift;
> my $iq = shift; 
> my $id = $iq->GetID();
> print "id = $id\n"; # works 
> my $type = $iq->GetType();
> print "type = $type\n"; #works 
> my $xmlns = $iq->GetQueryXMLNS();
> print "xmlns = $xmlns\n"; #works 
> foreach my $query ($iq->GetQuery->GetItems) {
> print ("JID = $query->GetItem()->GetJID\n"); # prints a
> hash
> print ("Name = $query->GetItem()->GetName\n"); #
> prints a hash
> print ("Subscription =
> $query->GetItem()->GetSubscription\n"); # prints a hash
> print ("Group = $query->GetItem()->GetGroup[0]\n"); #
> prints a hash
> }
> } 


__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com
_______________________________________________
jdev mailing list
jdev at jabber.org
http://mailman.jabber.org/listinfo/jdev



---------------------------------
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/20030127/f71ef587/attachment-0002.htm>


More information about the JDev mailing list