Ignore:
Timestamp:
Oct 18, 2009, 3:59:29 PM (12 years ago)
Author:
Alex Vandiver <alexmv@mit.edu>
Branches:
master, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
f3678c3
Parents:
99cc3dc
git-author:
Alex Vandiver <alexmv@mit.edu> (03/22/09 02:06:46)
git-committer:
Alex Vandiver <alexmv@mit.edu> (10/18/09 15:59:29)
Message:
Make Jabber try to reconnect when disconnected, at exponential intervals

Make the ConnectionManager store auth information on connect, and use
that auth information to try to reconnect and re-auth.  Use some
simple exponential backoff, capped at 5 minutes, as intervals for
reconnecting.
File:
1 edited

Legend:

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

    rf798d02 ra957e92  
    132132
    133133    foreach my $jid ( $conn->getJIDs() ) {
     134
     135        next unless $conn->jidActive($jid) or $conn->tryReconnect($jid);
     136
    134137        my $client = $conn->getConnectionFromJID($jid);
    135 
    136138        unless($client) {
    137139            $conn->removeConnection($jid);
     
    140142        my $status = $client->Process(0); # keep-alive
    141143        if ( !defined($status) ) {
    142             BarnOwl::error("Jabber account $jid disconnected!");
    143             do_logout($jid);
    144             next;
     144            $conn->scheduleReconnect($jid);
    145145        }
    146146        if ($::shutdown) {
     
    383383    }
    384384
    385     if ( $conn->jidExists($jidStr) ) {
     385    if ( $conn->jidActive($jidStr) ) {
    386386        BarnOwl::error("Already logged in as $jidStr.");
    387387        return;
     388    } elsif ($conn->jidExists($jidStr)) {
     389        return $conn->tryReconnect($jidStr, 1);
    388390    }
    389391
     
    453455                BarnOwl::error( "Error in connect: " . join( " ", @result ) );
    454456            } else {
     457                $conn->setAuth(
     458                    $jidStr,
     459                    {   %{ $vars{jlogin_authhash} },
     460                        password => $vars{jlogin_password}
     461                    }
     462                );
    455463                my $roster = $conn->getRosterFromJID($jidStr);
    456464                $roster->fetch();
     
    463471                $client->{fileno} = $client->getSocket()->fileno();
    464472                #queue_admin_msg("Connected to jabber as $fullJid ($client->{fileno})");
    465                 BarnOwl::add_dispatch($client->{fileno}, sub { $client->OwlProcess() });
     473                BarnOwl::add_dispatch($client->{fileno}, sub { $client->OwlProcess($fullJid) });
    466474
    467475                # populate completion from roster.
Note: See TracChangeset for help on using the changeset viewer.