Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (8)
As of 2024-04-18 13:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found