Guillermo Roditi wrote:
for( @domains ){
    my $aim = DJabberd::Component::External->new(
                                               listenport => 5270,
                                               secret     => 'some_secret',
                                              );
    $aim->finalize;
    my $vhost = DJabberd::VHost->new( %vhost_args, server_name => $_,);
    $vhost->register_subdomain("aim", $aim);
    $server->add_vhost($vhost);
}


It looks like you're missing $vhost->add_plugin($plugin) here...

(reformatted a little so that my email client wouldn't butcher it)

for( @domains ){
    my $aim = DJabberd::Component::External->new(
        listenport => 5270,
        secret     => 'some_secret',
    );
    $aim->finalize;
    my $vhost = DJabberd::VHost->new( %vhost_args, server_name => $_,);
    $vhost->add_plugin($plugin);
    $vhost->register_subdomain("aim", $aim);
    $server->add_vhost($vhost);
}

Some other points:

* I'd advise against using $_ like you are above, since DJabberd::Component::External->new might clobber it. It doesn't right now, and it definitely shouldn't, but you never know when someone will introduce a $_-clobbering bug.

* You're using the deprecated register_subdomain support, which might not actually even work anymore. (I vaugely remember Artur partially breaking it somewhere along the line.)

Here's the new (sadly, more long-winded) way to create a "subdomain". (Which is really just another vhost with local delivery configured.)

foreach my $base_name ( @domains ) {
    my $vhost = DJabberd::VHost->new(%vhost_args,
        server_name => $base_name,
    );
    my $aim = DJabberd::VHost->new(%vhost_args,
        server_name => "aim.".$base_name,
    );

    my $local_delivery = DJabberd::Delivery::Local->new();
    my $external_component = DJabberd::Component::External->new(
        listenport => 5270,
        secret     => 'some_secret',
    );
    my $local_vhosts_1 = DJabberd::Delivery::LocalVHosts->new(
        allowvhost => $base_name,
    );
    my $local_vhosts_2 = DJabberd::Delivery::LocalVHosts->new(
        allowvhost => "aim.".$base_name,
    );

    $local_delivery->finalize();
    $external_component->finalize();
    $local_vhosts_1->finalize();
    $local_vhosts_2->finalize();

    # Add the Local delivery plugin to $vhost
    $vhost->add_plugin($local_delivery);

    # Add the external component to $aim
    $aim->add_plugin($external_component);

    # Connect the two domains with the LocalVHosts delivery plugin
    $vhost->add_plugin($local_vhosts_2);
    $aim->add_plugin($local_vhosts_1);

    $server->add_vhost($vhost);
    $server->add_vhost($aim);
}
(not tested, so you'll probably have to tweak a bit to get it working)

The above is roughly equivalent to:
<VHost example.com>
    <Plugin DJabberd::Delivery::Local />
    <Subdomain aim>
        <Plugin DJabberd::Component::External>
            ListenPort 5270
            Secret some_secret
        </Plugin>
    </Subdomain>
</VHost>

It's probably also worth noting that as you've written this, with it creating a new AIM component each time, only the first will actually work because they'll all independently try to listen on the same port. For it to work, you'll need to run each instance on a separate port and connect one pyAIMt to each.

This isn't ideal, I realise; I've actually been working recently on trying to get the POE framework to co-operate with Danga::Socket so that the existing POE components for other IM protocols can potentially be used to make in-process IM transports, but I've not got it working just yet. I'm still trying to familiarize myself with how POE works.

Reply via email to