2010-04-26 63 views
2

CPAN上有Net::Msmgr模塊。它寫得很乾淨,乍看之下代碼看起來很值得信賴。然而這個模塊似乎是β和很少有文檔和沒有測試: -/爲什麼Perl的Net :: Msmgr在我嘗試進行身份驗證時掛起?

有沒有人用在生產這種模塊?我還沒有設法讓它現在運行,因爲它需要在應用程序中完成所有的事件循環處理,正如我已經說過的,很少有文檔和沒有工作的例子來研究。

這就是我這麼遠了:

#!/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(); 

這就是它輸出:

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 

而這一切,在這裏死了。登錄處理程序不會被觸發。我究竟做錯了什麼?

回答

-2

希望這些文件將幫助你

1)Net::Msmgr documentation

2)Net::Msmgr::Session

+0

謝謝,我閱讀。而且來源也是如此。 – codeholic 2010-04-26 09:45:29

+6

我的問題很難,因爲我總是試圖在詢問SO之前自己獲取信息。如果我說文檔很少,那就意味着我已經閱讀了所有我能找到的文檔(首先是關於CPAN的文檔),並且它沒有回答我的問題。我不是在問如何總結兩個數字。我接受回答我的問題的答案。這是否激勵?那麼,我不知道,那我該怎麼做?假裝? – codeholic 2010-04-26 11:52:49

+0

爲什麼 - 任何理由。 – Space 2010-04-27 08:51:41

相關問題