1 package OpenSRF::Transport::SlimJabber::Inbound;
2 use strict;use warnings;
3 use base qw/OpenSRF::Transport::SlimJabber::Client/;
5 use OpenSRF::Utils::Config;
6 use OpenSRF::Utils::Logger qw(:level);
8 my $logger = "OpenSRF::Utils::Logger";
12 This is the jabber connection where all incoming client requests will be accepted.
13 This connection takes the data, passes it off to the system then returns to take
14 more data. Connection params are all taken from the config file and the values
15 retreived are based on the $app name passed into new().
17 This service should be loaded at system startup.
21 # XXX This will be overhauled to connect as a component instead of as
22 # a user. all in good time, though.
26 sub unix_sock { return $unix_sock; }
30 my( $class, $app ) = @_;
31 $class = ref( $class ) || $class;
33 my $app_state = $app . "_inbound";
34 my $config = OpenSRF::Utils::Config->current;
37 throw OpenSRF::EX::Jabber( "No suitable config found" );
40 my $username = $config->transport->users->$app;
41 my $password = $config->transport->auth->password;
42 my $resource = 'system';
44 if (defined $config->system->router_target) {
45 $resource .= '_' . $config->env->hostname . "_$$";
48 my $self = __PACKAGE__->SUPER::new(
49 username => $username,
50 resource => $resource,
51 password => $password,
57 my $f = $config->dirs->sock_dir;
58 $unix_sock = join( "/", $f, $config->unix_sock->$app );
59 bless( $self, $class );
70 my $config = OpenSRF::Utils::Config->current;
71 my $routers = $config->system->router_target;
72 if (defined $routers) {
73 for my $router (@$routers) P
74 $self->send( to => $router,
75 body => "registering", router_command => "register" , router_class => $self->{app} );
80 my $sock = $self->unix_sock();
81 my $socket = IO::Socket::UNIX->new( Peer => $sock );
83 throw OpenSRF::EX::Socket( "Unable to connect to UnixServer: socket-file: $sock \n :=> $! " )
84 unless ($socket->connected);
86 my $o = $self->process( -1 );
88 if( ! defined( $o ) ) {
89 throw OpenSRF::EX::Jabber( "Listen Loop failed at 'process()'" );
97 throw OpenSRF::EX::Socket( "How did we get here?!?!" );