source: perl/modules/AIM/lib/Net/OSCAR/Callbacks/1/rate_change.pm @ 7a1c90d

barnowl_perlaim
Last change on this file since 7a1c90d was 7a1c90d, checked in by Geoffrey Thomas <geofft@mit.edu>, 16 years ago
Skeleton AIM module, and Net::OSCAR 1.925
  • Property mode set to 100644
File size: 866 bytes
Line 
1package Net::OSCAR::Callbacks;
2use strict;
3use warnings;
4use vars qw($connection $snac $conntype $family $subtype $data $reqid $reqdata $session $protobit %data);
5sub {
6
7my($rate, $worrisome);
8
9if($session->{rate_manage_mode} != OSCAR_RATE_MANAGE_NONE) {
10        delete $data{message_type};
11
12        my $cinfo = $connection->{rate_limits}->{$data{class_id}};
13        $cinfo->{$_} = $data{$_} foreach keys(%data);
14}
15
16
17if($data{current} <= $data{disconnect}) {
18        $rate = RATE_DISCONNECT;
19        $worrisome = 1;
20} elsif($data{current} <= $data{limit}) {
21        $rate = RATE_LIMIT;
22        $worrisome = 1;
23} elsif($data{current} <= $data{alert}) {
24        $rate = RATE_ALERT;
25        if($data{current} - $data{limit} < 500) {
26                $worrisome = 1;
27        } else {
28                $worrisome = 0;
29        }
30} else { # We're clear
31        $rate = RATE_CLEAR;
32        $worrisome = 0;
33}
34
35$session->callback_rate_alert($rate, $data{clear}, $data{window}, $worrisome, 0);
36
37};
Note: See TracBrowser for help on using the repository browser.