From da76e9c567eda51549678353011818ec9c1fc937 Mon Sep 17 00:00:00 2001 From: miker Date: Wed, 15 Jun 2005 14:14:25 +0000 Subject: [PATCH] adding routerless config support; adding local UNIX domain socket support git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@342 9efc2488-bf62-4759-914b-345cdb29e865 --- src/perlmods/OpenSRF/AppSession.pm | 2 +- src/perlmods/OpenSRF/Transport/SlimJabber/Client.pm | 13 ++++++++++--- src/perlmods/OpenSRF/Transport/SlimJabber/PeerConnection.pm | 8 ++++++-- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/perlmods/OpenSRF/AppSession.pm b/src/perlmods/OpenSRF/AppSession.pm index 7ece06f..c2de524 100644 --- a/src/perlmods/OpenSRF/AppSession.pm +++ b/src/perlmods/OpenSRF/AppSession.pm @@ -179,7 +179,7 @@ sub get_app_targets { my $app = shift; my $conf = OpenSRF::Utils::Config->current; - my $router_name = $conf->bootstrap->router_name; + my $router_name = $conf->bootstrap->router_name || 'router'; my $routers = $conf->bootstrap->domains; unless($router_name and $routers) { diff --git a/src/perlmods/OpenSRF/Transport/SlimJabber/Client.pm b/src/perlmods/OpenSRF/Transport/SlimJabber/Client.pm index 706699a..67d36b5 100644 --- a/src/perlmods/OpenSRF/Transport/SlimJabber/Client.pm +++ b/src/perlmods/OpenSRF/Transport/SlimJabber/Client.pm @@ -3,10 +3,12 @@ use strict; use warnings; use OpenSRF::EX; use base qw( OpenSRF ); use OpenSRF::Utils::Logger qw(:level); +use OpenSRF::Utils::Config; use Time::HiRes qw(ualarm); use Fcntl qw(F_GETFL F_SETFL O_NONBLOCK); use IO::Socket::INET; +use IO::Socket::UNIX; =head1 Description @@ -449,14 +451,19 @@ sub initialize { XML + my $sock_type = 'IO::Socket::INET'; + unless ($port > 0) { + $sock_type = 'IO::Socket::UNIX'; + } # --- 5 tries to connect to the jabber server my $socket; for(1..5) { $logger->transport( "$jid: Attempting to connect to server...$host:$port (Try # $_)", WARN ); - $socket = IO::Socket::INET->new( PeerHost => $host, - PeerPort => $port, - Proto => 'tcp' ); + $socket = $sock_type->new( PeerHost => $host, + PeerPort => $port, + Peer => $port, + Proto => 'tcp' ); $logger->transport( "$jid: $_ connect attempt to $host:$port", WARN ); last if ( $socket and $socket->connected ); sleep 3; diff --git a/src/perlmods/OpenSRF/Transport/SlimJabber/PeerConnection.pm b/src/perlmods/OpenSRF/Transport/SlimJabber/PeerConnection.pm index af93d36..330c665 100644 --- a/src/perlmods/OpenSRF/Transport/SlimJabber/PeerConnection.pm +++ b/src/perlmods/OpenSRF/Transport/SlimJabber/PeerConnection.pm @@ -56,12 +56,16 @@ sub new { my $username = $conf->bootstrap->username; my $password = $conf->bootstrap->passwd; - my $port = $conf->bootstrap->port; + my $port = $conf->bootstrap->port; my $resource = "${app}_drone_at_$h"; - my $host = $domains->[0]; # XXX for now... + my $host = $domains->[0]; # XXX for now... if( $app eq "client" ) { $resource = "client_at_$h"; } + unless ( $conf->bootstrap->router_name ) { + $username = 'router'; + $resource = $app; + } OpenSRF::EX::Config->throw( "JPeer could not load all necesarry values from config" ) -- 2.11.0