in reply to Re: CGI Net::AIM get_info()
in thread CGI Net::AIM get_info()

Trying to get the info of a 7 character screenname and using Data::Dumper, it simply prints:
$VAR1 = 27;
(Notice the 20+7 pattern)

Replies are listed 'Best First'.
Re: Re: Re: CGI Net::AIM get_info()
by Roger (Parson) on Jan 16, 2004 at 06:48 UTC
    I checked the source code of Net::AIM::Connection, where the get_info method is defined, and found that it returns the value returned by the send_to_AOL method. The following is the code of send_to_AOL:
    sub send_to_AOL { ... my $rv = send($self->{_socket}, $data, 0); ... return $rv; }
    Note that the return value of socket send is the number of characters sent. That explains why you are getting a numeric value in the return value of get_info. You have found a bug in the Net::AIM::Connection module it seems. ;-)

    I think you might be able to get around this problem by calling the method do_one_loop after the get_info, where do_one_loop reads the socket:
    $aim->get_info("screenname"); $response = $aim->do_one_loop();

      I tried that, but even 25 commands later, the socket still read "1":
      $aim->get_info("screenname"); $result = $aim->do_one_loop(); $count = 0; while($result eq "1" && $count <25) { $result = $aim->do_one_loop(); $count++; }
        Ok, I spent some time to study the source of Net::AIM, and got a few clues to how the module(s) work.

        Net::AIM has an event driven model. You need to set up handlers in your code to handle various events. For this particular exercise I assume that the name of the get_info event is indeed get_info. You will need to find out the exact name of the get_info event, by turning on the debug option in the module.
        ... # set up a handler to handle the 'get_info' event sub get_info_handler { # four arguments are passed into the handler, but we # are only interested in the second argument, the event my $event = $_[1]; # get the event # $event->{'args'} contains the returning messages # do the processing here ... ... } # set a handler for the 'get_info' event $aim->getconn()->set_handler('get_info', \&get_info_handler); $aim->get_info("screenname"); $aim->do_one_loop(); # this will invoke the event handler