in reply to Net::OSCAR: Having trouble getting started

w00t! Looks like I figured it out. Or rather, looks like I blindly stumbled on code which works. :)
#!/usr/bin/perl use Net::OSCAR qw(:standard); %signon = ( screenname => 'myscreenname', password => 'mypassword', local_ip => 'myip', ); $recipient = "myfriend"; $message = "mymessage"; sub signon_done { print "signed on\n"; $online = 1; } $oscar = Net::OSCAR->new(); $oscar->set_callback_signon_done(\&signon_done); $oscar->signon(%signon); while(1) { $oscar->do_one_loop(); if ($online) { $oscar->send_im($recipient, $message); sleep(5); } }
Apparently the $oscar->do_one_loop(); is a pretty important aspect. Thanks for your help!

- Justin

Replies are listed 'Best First'.
Re^2: Net::OSCAR: Having trouble getting started
by eric256 (Parson) on Jan 29, 2005 at 06:53 UTC
    Apparently the $oscar->do_one_loop(); is a pretty important aspect. Thanks for your help!

    Yes. That is actualy the meat of how it works. The AIM protocol counts on sending messages back and forth, if its like MSN it uses several connections while doing this. In order for that communication to work and not block your program, it is written in an event based style. This means you setup events to do certain things and then wait for the module to call those events. Inside your connection event the first thing received is actualy the $oscar object. You could then use that to send the message. the way it is currently setup its going to send your message every 5 seconds.


    ___________
    Eric Hodges
Re^2: Net::OSCAR: Having trouble getting started
by tcf03 (Deacon) on Jan 29, 2005 at 07:46 UTC
    $oscar->loglevel(5);
    or whatever loglevel you put in there, will also give you some useful info.