The module Net::XMPP::Client::GTalk is aimed at providing an easy to use wrapper around NET::XMPP class of modules for specific use with GTalk.

Although the majority of this can be achieved through Net::XMPP::Client there are several parameters that need to be fixed and it took me a good hour and half just to get the basics to work, which IMHO is too long.

Additionally Net::XMPP::Client provides call back functions which ( again IMHO ) is confusing/counter-intuitive/unnecessary in synchronous programs - And these are not just additional provisions but requirements.

There are also sections ( such as checking if a buddy is online ) that do not work and this module provides for a workaround.

Additionally Net::XMPP::Client::GTalk provides direct access to the NET::XMPP connection object, so all functions of the NET::XMPP class of modules.

Example ( from module POD ):

This example connects to GTalk and waits for a chat message from someone. It replies to that person with the chat message that it received. Additionally it will dump online buddies at regular intervals along with the contents of the message it receives.

You can quit this program by sending it the chat message 'exit'.

use Net::XMPP::Client::GTalk ; use Data::Dump qw( dump ) ; my $username ; # = '' ; Set GTalk username here [ WITHOUT '@gmail. +com' ]. my $password ; # = '' ; Set GTalk password here. unless( defined( $username ) and defined( $password ) ) { die( "SET YOUR GTALK USERNAME AND PASSWORD ABOVE!\n" ) ; } my $ob = new Net::XMPP::Client::GTalk( USERNAME => $username , PASSWORD => $password , ); my $require_run = 1 ; my $iteration = 1 ; while( $require_run ) { my $message = $ob->wait_for_message( 60 ) ; unless( $message ) { print "GOT NO MESSAGE - waiting longer\n" ; } if( $message->{ error } ) { print "ERROR \n" ; next ; } else { dump( $message ) ; } if( $message->{ message } eq 'exit' ) { print "Asked to exit by " . $message->{ from } . "\n" ; $message->{ message } = 'Exiting ... ' ; $require_run = 0 ; } $ob->send_message( $message->{ from }, $message->{ message } ) ; if( int( $iteration / 3 ) == ( $iteration / 3 ) ) { my @online_buddies = @{ $ob->get_online_buddies() } ; dump( \@online_buddies ) ; } $iteration++ ; } exit() ;
I have contacted the author of Net::XMPP as I am adding to his/her namespace

Would greatly appreciate any kind of feedback!

Update: This module is now on CPAN here

In reply to RFC: Net::XMPP::Client::GTalk by tmharish

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.