Howdy,

If no one's released a PoCo::Net::OSCAR (i.e. the public face of AOL's
IM), I've got one to offer.

However, I was hoping for a bit of feedback first, because I'm not sure
I've gone about it in the best way.  The Net::OSCAR module is very nice
in that it can use other event loops.  The only hitch is that it thinks
in terms of filenos and it looks like POE thinks in terms of sockets and
handles.  I'm not too well-versed in this area, but after a bit of trial
and error, I came up with this:

# sign on, and set up POE to monitor all the connections
$_[HEAP]->{oscar}->signon( %args );

for my $connection (@{ $_[HEAP]->{oscar}->{connections} }) {
   next unless $connection->{socket};
   $_[KERNEL]->select( $connection->{socket}, 'process', 'process',
'process' );
}

[... below ... ]

sub process {
    while (1) {
        my ($rin, $win) = $_[HEAP]->{oscar}->selector_filenos();
        my $ein = $rin | $win;

        my $nfound = select($rin, $win, $ein, .01);

        last unless $nfound;

        $_[HEAP]->{oscar}->process_connections( \$rin, \$win, \$ein );
    }
}

This works fine, but it seems a bit heavy on the selects.  Is there a
better way?

Thanks,
Dan

Reply via email to