paulehr has asked for the wisdom of the Perl Monks concerning the following question:

Hello fellow monks,

I am currently writing a simple Perl AOL instant messenger bot to do my bidding. One of the features i would like to add into the bot is that for some reason if the bot gets disconnected from the AIM network (cable connection drops, etc), It will attempt to reconnect. Now will this happen automatically with Net::OSCAR or will i need to code something in that will do it? If so can someone point me to some examples?

Thanks for the help!

Replies are listed 'Best First'.
Re: connection question with Net::OSCAR
by andyford (Curate) on Dec 07, 2006 at 15:06 UTC

    You could cut the connection and see what happens.

    non-Perl: Andy Ford

      I went and cut the connection. Waited a few minutes for everything to drop. Then i restored the connection. The bot never recovers and just times out. I have to manually kill the bot and restart it for it to reconnect back to the aim network. So now is there a way through Net::OSCAR where it can handle being disconnected and recover from it or will I have to come up with a different solution for handling it being dropped from the network?

        I'm not familiar with the module, but if you can't find any auto reconnect methods in the documentation, then you'll have to do it yourself.
        Just do some trivial operation that you know should always succeed and reconnect if it fails.

        non-Perl: Andy Ford

      ouch, i feel like a boob. I'll try that and see what happens :)

        I've missed the obvious so many times myself...

        non-Perl: Andy Ford

Re: connection question with Net::OSCAR
by jalexandre (Initiate) on Dec 07, 2006 at 15:21 UTC
    Maybe this can give you some ideas: http://search.cpan.org/~matthewg/Net-OSCAR-1.925/lib/Net/OSCAR.pm#ERROR_HANDLING I see something about you want in TIME-DELAYED section. 's
      cool, I'll check that and see if i can come up with anything. Thanks!
Re: connection question with Net::OSCAR
by bingos (Vicar) on Dec 08, 2006 at 08:17 UTC

    Net::OSCAR appears to have a callback for connection status 'connection_changed', you could probably check for 'deleted' and initiate a reconnection from there.

      I saw that in there, but was not sure if that was what i need or not. I am struggling with the documentation a little bit and still trying to make sense of a few things. Thanks for the input!