Hi, I'm writing a AIM bot using Net::OSCAR. If you're unfamilar with the module, it basically sets each AIM event (receiving an IM, someone going offline, etc) as a different callback (I would appreciate someone directing me towards a place I could get more information about these callbacks; I've looked and my searches have come up mostly empty) and then calls a function in your code. Some functions rely on the result of other functions to work properly (ie the function that changes the buddylist ( commit_buddylist() ) must recieve an status message about the previous change ( buddylist_ok() or buddylist_error() ) before it can be called again, ).

The problem I'm experiencing is the program just rushes through execution without waiting for certain events to occur.
My question is: how do you stop excecution at a certain point, wait for a particular callback (or event) and then continue? Ideally, it should handle timing out after a certain time as well (if the expected result hasn't been returned).
For example:
# assume $bot is a valid Net::OSCAR object # callbacks $bot->set_callback_signon_done(\&signon_done); $bot->set_callback_buddylist_ok(\&buddylist_ok); $bot->set_callback_buddylist_error(\&buddylist_error); $bot->signon($sn,$passwd); #this logs you into the net # Program should wait here until signon_done # parse a list of @buddies to be added (this works) foreach (@buddies) { $bot->add_buddy($grp, $_) #adds a user $bot->commit_buddylist(); # sets changes to the server # program should wait here until either # buddylist_ok() or buddylist_error() is returned } # ... do other stuff

Even if you aren't familar with Net::Oscar, I hope you understand what I'm trying to accomplish. If you don't understand anything above, please tell me and I'll try to clarify.

Thanks in advance,
-mike

In reply to Waiting for callback event by cow4263

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.