Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

RFC: Net::XMPP::Client::GTalk

by tmharish (Friar)
on Jan 18, 2013 at 12:20 UTC ( #1014043=perlmeditation: 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

Comment on RFC: Net::XMPP::Client::GTalk
Download Code
Re: RFC: Net::XMPP::Client::GTalk
by Arunbear (Parson) on Jan 18, 2013 at 13:23 UTC
    Where is the source code for Net::XMPP::Client::GTalk?

    updated: If you post a link to it, you may get additional valuable feedback.

      This is more of a pre-release RFC.

      I could upload the code someplace if that will help

      update: The module can be downloaded from here

      Update: Modified link to point to CPAN.

        Have you considered hosting it on Github (or similar site like Bitbucket or Google code)? In addition to the version control and collaborative features, these services also make it easy to browse the source code (without needing to download and unpack a zip file).

        A random example.

      Just saw your update

      Update: The module can be downloaded from here

      Update: Modified link to point to CPAN.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://1014043]
Approved by marto
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (7)
As of 2014-12-20 10:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (95 votes), past polls