- Timestamp:
- Oct 18, 2009, 3:59:29 PM (15 years ago)
- Branches:
- master, release-1.10, 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)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
perl/modules/Jabber/lib/BarnOwl/Module/Jabber/ConnectionManager.pm
r8ff511d ra957e92 41 41 if $self->{$jidStr}->{Client}; 42 42 delete $self->{$jidStr}; 43 44 return 1; 45 } 46 47 sub scheduleReconnect { 48 my $self = shift; 49 my $jidStr = shift; 50 return 0 unless exists $self->{$jidStr}; 51 BarnOwl::admin_message(Jabber => "Disconnected from jabber account $jidStr"); 52 53 BarnOwl::remove_dispatch($self->{$jidStr}->{Client}->{fileno}) if $self->{$jidStr}->{Client}->{fileno}; 54 $self->{$jidStr}->{Client}->Disconnect() 55 if $self->{$jidStr}->{Client}; 56 57 $self->{$jidStr}->{Status} = "reconnecting"; 58 $self->{$jidStr}->{ReconnectBackoff} = 5; 59 $self->{$jidStr}->{ReconnectAt} = time + $self->{$jidStr}->{ReconnectBackoff}; 60 return 1; 61 } 62 63 sub setAuth { 64 my $self = shift; 65 my $jidStr = shift; 66 $self->{$jidStr}->{Auth} = shift; 67 } 68 69 sub tryReconnect { 70 my $self = shift; 71 my $jidStr = shift; 72 my $force = shift; 73 74 return 0 unless exists $self->{$jidStr}; 75 return 0 unless $self->{$jidStr}{Status} eq "reconnecting"; 76 return 0 unless $force or (time > $self->{$jidStr}{ReconnectAt}); 77 78 $self->{$jidStr}->{ReconnectBackoff} *= 2; 79 $self->{$jidStr}->{ReconnectBackoff} = 60*5 80 if $self->{$jidStr}->{ReconnectBackoff} > 60*5; 81 $self->{$jidStr}->{ReconnectAt} = time + $self->{$jidStr}->{ReconnectBackoff}; 82 83 my $status = $self->{$jidStr}->{Client}->Connect; 84 return 0 unless $status; 85 86 my @result = $self->{$jidStr}->{Client}->AuthSend( %{ $self->{$jidStr}->{Auth} } ); 87 if ( !@result || $result[0] ne 'ok' ) { 88 $self->removeConnection($jidStr); 89 BarnOwl::error( "Error in jabber reconnect: " . join( " ", @result ) ); 90 return 0; 91 } 92 93 BarnOwl::admin_message(Jabber => "Reconnected to jabber as $jidStr"); 94 $self->{$jidStr}{Status} = "available"; 43 95 44 96 return 1; … … 88 140 } 89 141 142 sub jidActive { 143 my $self = shift; 144 my $jidStr = shift; 145 return(exists $self->{$jidStr} and $self->{$jidStr}{Status} eq "available"); 146 } 147 90 148 sub sidExists { 91 149 my $self = shift; … … 110 168 my $jid = shift; 111 169 $jid = $jid->GetJID('full') if UNIVERSAL::isa($jid, 'Net::XMPP::JID'); 112 return $self->{$jid}->{Client} if exists $self->{$jid};170 return $self->{$jid}->{Client} if $self->jidActive($jid); 113 171 } 114 172 … … 127 185 my $jid = shift; 128 186 $jid = $jid->GetJID('full') if UNIVERSAL::isa($jid, 'Net::XMPP::JID'); 129 return $self->{$jid}->{Roster} if exists $self->{$jid};187 return $self->{$jid}->{Roster} if $self->jidExists($jid); 130 188 } 131 189
Note: See TracChangeset
for help on using the changeset viewer.