1 package OpenSRF::Transport::Jabber::JPeerConnection;
3 use base qw/OpenSRF::Transport::Jabber::JabberClient/;
4 use OpenSRF::Utils::Config;
5 use OpenSRF::Utils::Logger qw(:level);
9 Represents a single connection to a remote peer. The
10 Jabber values are loaded from the config file.
12 Subclasses OpenSRF::Transport::JabberClient.
20 The $appname parameter tells this class how to find the correct
21 Jabber username, password, etc to connect to the server.
29 my( $class, $app ) = @_;
30 my @keys = keys %apps_hash;
31 OpenSRF::Utils::Logger->transport(
32 "Requesting peer for $app and we have @keys", INTERNAL );
33 return $apps_hash{$app};
39 my( $class, $app ) = @_;
40 my $config = OpenSRF::Utils::Config->current;
43 throw OpenSRF::EX::Config( "No suitable config found" );
46 my $app_stat = $app . "_peer";
47 my $host = $config->transport->server->primary;
48 my $username = $config->transport->users->$app;
49 my $password = $config->transport->auth->password;
50 my $debug = $config->transport->llevel->$app_stat;
51 my $log = $config->transport->log->$app_stat;
52 my $resource = $config->env->hostname . "_$$";
54 OpenSRF::EX::Config->throw( "JPeer could not load all necesarry values from config" )
55 unless ( $host and $username and $password and $resource );
58 my $self = __PACKAGE__->SUPER::new(
59 username => $username,
61 resource => $resource,
62 password => $password,
67 bless( $self, $class );
69 $self->SetCallBacks( message => sub {
71 OpenSRF::Utils::Logger->transport(
72 "JPeer passing \n$msg \n to Transport->handler for $app", INTERNAL );
73 OpenSRF::Transport->handler( $app, $msg ); } );
75 $apps_hash{$app} = $self;
76 return $apps_hash{$app};