Ignore:
Timestamp:
Feb 15, 2008, 12:56:49 AM (13 years ago)
Author:
Alejandro R. Sedeño <asedeno@mit.edu>
Branches:
master, barnowl_perlaim, debian, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
18a54ee
Parents:
a6a4155
Message:
Initial select() changes.
stdin, zephyr, jabber, and irc are checked and have dispatch functions.
aim is hacked in -- not entirely pretty, but documented and isolated.
We still want timers.
Location:
perl/modules/Jabber/lib/BarnOwl/Module
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • perl/modules/Jabber/lib/BarnOwl/Module/Jabber.pm

    r879e7e94 r9c7a701  
    116116            BarnOwl::error("Connection for $jid undefined -- error in reload?");
    117117        }
    118 
    119         my $status = $client->Process(0);
    120         if ( !defined($status) ) {
    121             BarnOwl::error("Jabber account $jid disconnected!");
    122             do_logout($jid);
    123         }
    124118        if ($::shutdown) {
    125119            do_logout($jid);
    126             return;
     120            next;
    127121        }
    128122        if ($vars{status_changed}) {
     
    387381                $conn->renameConnection($jidStr, $fullJid);
    388382                queue_admin_msg("Connected to jabber as $fullJid");
     383                # The remove_dispatch() method is called from the
     384                # ConnectionManager's removeConnection() method.
     385                BarnOwl::add_dispatch($client->getSocket()->fileno(), sub { $client->OwlProcess() });
    389386            }
    390387        }
  • perl/modules/Jabber/lib/BarnOwl/Module/Jabber/Connection.pm

    r892568b r9c7a701  
    110110
    111111
     112=head2 getSID
     113
     114Returns the StreamID for this connection.
     115
     116=cut
     117
     118sub getStreamID {
     119    my $self = shift;
     120    return $self->{SESSION}->{id} || "";
     121}
     122
     123=head2 getSocket
     124
     125Returns the IO::Socket for this connection.
     126
     127=cut
     128
     129sub getSocket {
     130    my $self = shift;
     131    my $sid = getStreamID($self);
     132    return $self->{STREAM}->{SIDS}->{$sid}->{sock} || -1;
     133}
     134
     135=head2 OwlProcess
     136
     137Non-blocking connection processing. For use in a select loop.
     138
     139=cut
     140
     141sub OwlProcess {
     142    my $self = shift;
     143    my $status = $self->Process(0);
     144    if ( !defined($status) ) {
     145        my $jid = $self->{SESSION}->{FULLJID};
     146        BarnOwl::error("Jabber account $jid disconnected!");
     147        do_logout($jid);
     148    }
     149}
     150
    112151=head1 SEE ALSO
    113152
  • perl/modules/Jabber/lib/BarnOwl/Module/Jabber/ConnectionManager.pm

    r7f33c18 r9c7a701  
    3737    return 0 unless exists $self->{$jidStr};
    3838
     39    BarnOwl::remove_dispatch($self->{$jidStr}->{Client}->getSocket()->fileno());
    3940    $self->{$jidStr}->{Client}->Disconnect()
    4041      if $self->{$jidStr}->{Client};
     
    5152    return 0 if $oldJidStr eq $newJidStr;
    5253
    53     $self->{$newJidStr} = $self->{$oldJidStr}; 
     54    $self->{$newJidStr} = $self->{$oldJidStr};
    5455    delete $self->{$oldJidStr};
    5556    return 1;
Note: See TracChangeset for help on using the changeset viewer.