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

Greetings,

I've recently written a pager module for the Big Brother monitor suite with Net::AIM perl module and had someone request that I modify it such that it keeps it's connection open indefinitely. It currently will connect, send an alert, wait 2 minutes then disconnect. The only problem I have with this is I have absolutely no idea how to achieve this. I'd thought of letting it connect on the first alert and remain connected but I don't know how to tie further alerts into it to allow them to share an open connection. I'm hoping it will be something fairly simple but I've never tried anything likr this before.

Any words of wisdom would be MUCH appreciated (I hate to let my users down).

sol

Replies are listed 'Best First'.
Re: persistant IM
by The Mad Hatter (Priest) on Jan 16, 2004 at 02:55 UTC
    I don't know anything about the "Big Brother monitor suite", but I imagine there might be a way to provide initialization code that's run when your module is loaded? If so, connect in there and have the message handler use the Net::AIM object you created in the init. Or, have the message handler connect if there isn't a Net::AIM object already, and then pass that object around where/when-ever you need it.

    Anyway, seeing some code or a better description of how the process works for Big Brother might make for better answers.

      Big Brother (bb4.com) utilizes a pager script which can be user-defined. The script itself can be found at http://www.deadcat.net/3/aim. The script is essentially stand-alone and was based on the perldocs for Net::AIM and several AIMbots to see what was involved (it's not exactly the prettiest code I admit). It already has to initialize a connection but I'm unsure how to go about having it utilize an existing connection since the script is essentially run from scratch each time it's called.
        If your script gets run from scratch on every call, and you can't change that, it looks like you're going to have to split it into a client-server architechture. That means, have one piece (the server) that runs all the time, holding the AIM connection open, and listening for things to do from the other piece (the client), which gets rerun every time, and contacts the server script with whatever it has to send.

        There are several ways to communicate between client and server, try reading up on sockets and IPC in the perlipc manpage.

        C.

Re: persistant IM
by stevecomrie (Beadle) on Jan 16, 2004 at 15:07 UTC
    You could always try running the Net::AIM script in a continuous loop. And have a second script (the pager) write a file to a directory that the AIM script will then read, send and delete.

    In this case the pager module isn't doing the actual sending of the message, it's relying on the fact that the Net::AIM module will always be running.