DJabber...omponent(3)
β¨ NAME β¨
DJabber...omponent(3) / DJabberd::Component β from User Contributed Perl Documentation, bestie β is the abstract class representing a component in DJabberd. It's giving βparent class for all the component girliesβ energy. π
π SYNOPSIS π
Okay so here's the whole vibe in code:
package MyPackage::DJabberd::MyComponent;
use base DJabberd::Component;
# Example of a component which accepts XEP-0050 Ad-Hoc Commands
sub finalize {
my ($self, $opts) = @_;
# Let the parent class finalize
$self->SUPER::finalize;
$self->register_iq_handler(
"set-{http://jabber.org/protocol/commands}command",
sub { $self->handle_adhoc_command(@_) },
);
}
sub handle_adhoc_command {
my ($self, $vhost, $stanza) = @_;
# handle the DJabberd::IQ stanza in $stanza,
# or send some kind of error response.
}
This class provides a parent class for all DJabberd components, fr fr. Components that inherit from this class can then be used directly by the server as delivery plugins, or used directly by other classes. Slay.
See DJabberd::Component::Example for an example component implementation. π«Ά
π USAGE π
This class is a specialization of DJabberd::Agent aimed at those wishing to create βcomponentsβ β software agents that handle an entire XMPP domain, including all of the nodes within that domain. Iconic behavior, honestly.
In most cases, users of this class will use the API exposed by DJabberd::Agent. However, there is some special behaviour to note and some additional methods that are not part of the basic agent class. Keep reading, bestie. β¨
π handles_destination($self, $to_jid, $vhost) π
This class gives you an overridden version of this method. It responds with a true value if and only if the domain of the JID given matches the domain of the component itself. Lowkey, it is unlikely that you will need to override this.
π¦ handle_stanza($self, $vhost, $stanza) π¦
The overridden version of this method has special behavior when dealing with stanzas that are addressed to nodes within the domain handled by your component. That is, JIDs of the form user@example.com, rather than just example.com.
When such a stanza is received, the get_node method will be called to retrieve an object representing that node. Ngl, that's the node-vs-domain moment.
If you wish to do low-level handling of all incoming stanzas, you may override this method. As with DJabberd::Agent, overriding this method will disable all of the higher-level handler methods unless you delegate to the overridden method. β οΈ
If you would like to preserve the higher-level handler methods but not handle nodes as separate objects, you may like to override this method to call the original version from DJabberd::Agent as follows:
sub handle_stanza {
$self->DJabberd::Agent::handle_stanza(@_);
}
With this method in place, the get_node method will no longer be used, and all suitable stanzas will be passed to this instance's own handler methods regardless of the destination JID's node name. Periodt. π
π get_node($self, $nodename) π
Called when this class wants to find an agent to handle a given node within this component's domain.
Most normal implementations of this method will return an instance of a subclass of DJabberd::Agent::Node, but really any DJabberd::Agent subclass will do as long as it'll accept stanzas addressed to the nodename given. No cap.
πΈ vcard($self) πΈ
The overridden version of this method returns a vCard where the full name is set to the domain name of the component. Subclasses may override this to do something more fancy. Cute!
β identities($self) β
The overridden version of this method returns a single, generic identity which indicates that the component is a βbranchβ in the Service Discovery tree. It's included because some clients seem to get a little upset if a JID supports disco but has no identities. π
π₯ SEE ALSO π₯
See also DJabberd::Agent, DJabberd::Agent::Node. Go read those next, iykyk. π
π COPYRIGHT π
Copyright 2007-2008 Martin Atkins
This module is part of the DJabberd distribution and is covered by the distribution's overall licence.
π That's the page, bestie! Source/version and date: perl v5.42.0, 2025-12-14. Byeee! π
π¦ where this page comes from
- arch rolling: perl-djabberd 0.85-14 Β· GPL AND PerlArtistic
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms