[RFC]: improve behaviour when using as an external component

Pedro Melo melo at simplicidade.org
Fri Feb 2 15:16:27 UTC 2007


Hi,

I've been writing an external component using DJabberd and  
DJabberd::Delivery::ComponentConnection plugin.

It's a very good base to do it, very fast, compared to my previous  
versions using POE.

Yet, DJabberd is geared towards servers and for each component, he  
starts a C2S listening socket. :)

I've made a small patch (attached) that add a Standalone boolean  
configuration variable. If set to a true value (default is false), it  
stops DJabberd from binding C2S, S2S and some warnings. You can still  
enable C2S if you specifically ask for it.

I don't know if this is the best way to do it. Other suggestions are  
most welcome.

-------------- next part --------------
Index: trunk/common/perl_libs/DJabberd.pm
===================================================================
--- trunk/common/perl_libs/DJabberd.pm (revision 848)
+++ trunk/common/perl_libs/DJabberd.pm (revision 854)
@@ -63,4 +63,5 @@
         'share_parsers' => 1,
         'monitor_host' => {},
+        'standalone'  => 0, # if true, disables most X2s_port's and other stuff
     };
 
@@ -99,4 +100,15 @@
     my ($self, $val) = @_;
     $self->{share_parsers} = as_bool($val);
+}
+
+sub standalone { $_[0]{standalone} }
+
+# Use it with external components that connect to a jabber server
+# disables most of the server stuff
+sub set_config_standalone {
+    my ($self, $val) = @_;
+    $self->{standalone} = as_bool($val);
+    $self->{c2s_port} = 0;
+    $self->{s2s_port} = 0;
 }
 
@@ -275,5 +287,5 @@
         close(PIDFILE);
     }
-    $self->start_c2s_server();
+    $self->start_c2s_server() if $self->{c2s_port};
 
     # {=s2soptional}
Index: trunk/common/perl_libs/DJabberd/VHost.pm
===================================================================
--- trunk/common/perl_libs/DJabberd/VHost.pm (revision 848)
+++ trunk/common/perl_libs/DJabberd/VHost.pm (revision 854)
@@ -106,5 +106,5 @@
     }
 
-    unless ($self->has_plugin_of_type("DJabberd::Delivery::Local")) {
+    unless ($self->server->standalone || $self->has_plugin_of_type("DJabberd::Delivery::Local")) {
         $logger->logwarn("No DJabberd::Delivery::Local delivery plugin configured");
     }
@@ -114,4 +114,5 @@
     }
 
+    # FIXME: Acho que precisamos aqui de um $self->server-standalone para não fazer isto em componentes externos (SAPO)
     unless ($self->are_hooks("PresenceCheck")) {
         $self->add_plugin(DJabberd::PresenceChecker::Local->new);
-------------- next part --------------

Thanks,
--
Pedro Melo
Blog: http://www.simplicidade.org/notes/
Jabber ID: melo at simplicidade.org
Use Jabber!




More information about the Djabberd mailing list