views:

94

answers:

1

There's Net::Msmgr module on CPAN. It's written clean and the code looks trustworthy at the first glance. However this module seems to be beta and there is little documentation and no tests :-/

Has anyone used this module in production? I haven't managed to make it run by now, because it requires all event loop processing to be done in the application and as I've already said there is little documentation and no working examples to study.

That's where I've gone so far:

#!/usr/bin/perl
use strict;
use warnings;

use Event;
use Net::Msmgr::Object;
use Net::Msmgr::Session;
use Net::Msmgr::User;

use constant DEBUG => 511;
use constant EVENT_TIMEOUT => 5; # seconds

my ($username, $password) = qw/[email protected] my.password/;
my $buddy = '[email protected]';

my $user = Net::Msmgr::User->new(user => $username, password => $password);
my $session = Net::Msmgr::Session->new;
$session->debug(DEBUG);
$session->login_handler(\&login_handler);
$session->user($user);

my $conv;

sub login_handler {
    my $self = shift;
    print "LOGIN\n";
    $self->ui_state_nln;
    $conv = $session->ui_new_conversation;
    $conv->invite($buddy);
}

our %watcher;

sub ConnectHandler {
    my ($connection) = @_;
    warn "CONNECT\n";
    my $socket = $connection->socket;
    $watcher{$connection} = Event->io(fd => $socket,
                                      cb => [ $connection, '_recv_message' ],
                                      poll => 're',
                                      desc => 'recv_watcher',
                                      repeat => 1);
}

sub DisconnectHandler {
    my $connection = shift;
    print "DISCONNECT\n";
    $watcher{$connection}->cancel;
}

$session->connect_handler(\&ConnectHandler);
$session->disconnect_handler(\&DisconnectHandler);

$session->Login;

Event::loop();

That's what it outputs:

Dispatch Server connecting to: messenger.hotmail.com:1863
Dispatch Server connected
CONNECT
Dispatch Server >>>VER 1 MSNP2 CVR0
--> VER 1 MSNP2 CVR0
Dispatch Server >>>USR 2 MD5 I [email protected]
--> USR 2 MD5 I [email protected]
Dispatch Server <<<VER 1 CVR0
<-- VER 1 CVR0

And that's all, here it hangs. The handler on login is not being triggered. What am I doing wrong?

A: 

Hope these documents will help you out

1) Net::Msmgr documentation

2) Net::Msmgr::Session

Space
Thank you, I read them. And the source, too.
codeholic
I think you should also start accepting answers for your questions. This will motivate people to help give answers to your questions. 44% accept rate is very low.
Space
My questions are pretty hard, since I'm always trying to get information by myself before asking on SO. If I say that there's little documentation, that means that I've already read all documentation I could find (documentation on CPAN in the first place) and it hasn't answer my question. I'm not asking about how to sum up two numbers. And I accept answers that answer my questions. Is that demotivation? Well, I don't know, what should I do then? Pretend?
codeholic
Why -ve, any reason.
Space