2

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/my.username@live.com my.password/;
my $buddy = 'your.username@live.com';

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 my.username@live.com
--> USR 2 MD5 I my.username@live.com
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?

brian d foy
  • 129,424
  • 31
  • 207
  • 592
codeholic
  • 5,680
  • 3
  • 23
  • 43

1 Answers1

-2

Hope these documents will help you out

1) Net::Msmgr documentation

2) Net::Msmgr::Session

Space
  • 7,049
  • 6
  • 49
  • 68
  • 6
    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 Apr 26 '10 at 11:52