Hi, all, I'm trying to write a simple Perl script to log in, get a list of subscribed JIDs that are online, and then log off. The documentation for Net::XMPP indiates that a Roster object will do this:
http://search.cpan.org/~reatmon/Net-XMPP-1.0/lib/Net/XMPP/Protocol.pm Roster() - returns a Net::XMPP::Roster object. This will automatically intercept all of the roster and presence packets sent from the server and give you an accurate Roster. For more information please read the man page for Net::XMPP::Roster. And http://search.cpan.org/~reatmon/Net-XMPP-1.0/lib/Net/XMPP/Roster.pm online(jid) - return 1 if the JID is online, undef otherwise. The jid can either be a string, or a Net::XMPP::JID object. Here's a simple test program that should do what I want, however the online() method just doesn't seem to return anything. Am I completely wrong about what the Roster object does, or could this be a bug? Thanks, Erik # Simple test code taken from # http://www.pervasive-network.org/SPIP/Google-Talk-with-perl-bis and # modified to try to grab Presence updates via the Roster. use Net::XMPP; my $username = 'tester1'; my $password = 'tester1pass'; my $user = '[EMAIL PROTECTED]'; my $resource = 'TestingPerl'; my $hostname = 'talk.google.com'; my $port = 5222; my $componentname = 'gmail.com'; my $connectiontype = 'tcpip'; my $tls = 1; # Connect to Google Talk my $Connection = new Net::XMPP::Client(); $Connection->Connect( hostname => $hostname, port => $port, componentname => $componentname, connectiontype => $connectiontype, tls => $tls ); my $sid = $Connection->{SESSION}{id}; $Connection->{STREAM}->{SIDS}->{$sid}->{hostname} = $componentname; $Connection->AuthSend( username => $username, password => $password, resource => $resource ); # Send empty presenece => I'm available! $Connection->PresenceSend(); my $r = Net::XMPP::Roster->new(connection=>$Connection); $Connection->RosterRequest(); my $isOnline = $r->online($user); print "$user isOnline = $isOnline\n"; $Connection->Disconnect(); exit();
