jabberd14  1.6.2
Public Member Functions | Protected Member Functions
xmppd::instance_base Class Reference

#include <jabberd.h>

Inheritance diagram for xmppd::instance_base:
xmppd::proxy65::proxy65 xmppd::resolver::resolver

Public Member Functions

 instance_base (instance i, xmlnode x)

Protected Member Functions

virtual result on_packet (dpacket dp)
virtual result on_stanza_packet (dpacket dp)
virtual result on_xdb_packet (dpacket dp)
virtual result on_log_packet (dpacket dp)
virtual result on_route_packet (dpacket dp)
virtual result on_message_stanza (jpacket p)
virtual result on_presence_stanza (jpacket p)
virtual result on_iq_stanza (jpacket p)
virtual result on_subscription_stanza (jpacket p)
virtual void on_heartbeat ()
void set_heartbeat_interval (int interval)
void deliver (dpacket p)
void deliver (xmlnode x)
void deliver_fail (dpacket p, const std::string &reason_text)
void bounce_stanza (xmlnode x, xterror xterr)
std::string get_instance_id ()
logmessage log (loglevel level)
xmlnode get_instance_config ()

Detailed Description

class that implements the basic functionality for a component in the server


Constructor & Destructor Documentation

constructor to create an OOP instance from jabberd14's instance structure

Parameters:
ithe instance struct for this component
xconfiguration element that caused this instance to be loaded

References get_instance_id(), o_DELIVER, and register_phandler().


Member Function Documentation

void xmppd::instance_base::bounce_stanza ( xmlnode  x,
xterror  xterr 
) [protected]

create a bounce for a stanza, send this bounce back

This method consumes the stanza!

Note:
you should not bounce subscription stanzas. Bouncing them creates presence errors, not subscription errors (which do not exist in XMPP)
Parameters:
xthe stanza that should get bounced
xterrthe error reason used to bounce the stanza

References deliver(), and jutil_error_xmpp().

Referenced by on_iq_stanza(), on_message_stanza(), and on_presence_stanza().

void xmppd::instance_base::deliver ( dpacket  p) [protected]

send out a stanza

Parameters:
pthe packet containing the stanza, that should be sent

Referenced by bounce_stanza(), and deliver().

void xmppd::instance_base::deliver ( xmlnode  x) [protected]

send out a stanza

Parameters:
xthe xmlnode representing the stanza that should be sent

References deliver(), and dpacket_new().

void xmppd::instance_base::deliver_fail ( dpacket  p,
const std::string &  reason_text 
) [protected]

reject accepting a packet

Parameters:
pthe packet that could not sucessfully be processed
reason_texttextual reason why the packet has been rejected

Referenced by on_log_packet(), on_packet(), on_route_packet(), on_stanza_packet(), and on_xdb_packet().

get instance's configuration

Returns:
the configuration root node of the instance, NULL if no configuration (should NOT be freed)

References j_strcmp(), instance_struct::x, xmlnode_get_firstchild(), xmlnode_get_namespace(), xmlnode_get_nextsibling(), and xmlnode_get_type().

std::string xmppd::instance_base::get_instance_id ( ) [protected]

get the (main) ID of this instance

Returns:
id of this instance

References instance_struct::id.

Referenced by instance_base().

get a logmessage, that can be used to generate a message that gets logged

Parameters:
levelthe loglevel to use
Returns:
logmessage that can be used to stream message to
void xmppd::instance_base::on_heartbeat ( ) [protected, virtual]

event that gets fired regularly

result xmppd::instance_base::on_iq_stanza ( jpacket  p) [protected, virtual]

event that handles received iq stanzas

The default implementation is to bounce the stanza

Parameters:
pthe received message stanza
Returns:
should normally return r_DONE if the stanza has been handled (for other possible values see the result type)

References bounce_stanza(), and r_DONE.

Referenced by on_stanza_packet().

result xmppd::instance_base::on_log_packet ( dpacket  dp) [protected, virtual]

event that handles received packets, that contain a normal stanza (type p_LOG)

The default implementation is to bounce the packet

Parameters:
dpthe packet containing the stanza
Returns:
should normally return r_DONE if the packet has been handled (for other possible values see the result type)

References deliver_fail(), and r_DONE.

Referenced by on_packet().

result xmppd::instance_base::on_message_stanza ( jpacket  p) [protected, virtual]

event that handles received message stanzas

The default implementation is to bounce the stanza

Parameters:
pthe received message stanza
Returns:
should normally return r_DONE if the stanza has been handled (for other possible values see the result type)

References bounce_stanza(), and r_DONE.

Referenced by on_stanza_packet().

result xmppd::instance_base::on_packet ( dpacket  dp) [protected, virtual]

event that handles received packets

The default implementation of this handler checks the type of packet that has been received and calls the relevant handler: on_stanza_packet(), on_xdb_packet(), on_log_packet(), or on_route_packet()

Parameters:
dppacket that has to be handled
Returns:
should normally return r_DONE if the packet is handled (for other possible values see the result type)

References deliver_fail(), on_log_packet(), on_route_packet(), on_stanza_packet(), on_xdb_packet(), p_LOG, p_NORM, p_ROUTE, p_XDB, r_DONE, r_ERR, and dpacket_struct::type.

result xmppd::instance_base::on_presence_stanza ( jpacket  p) [protected, virtual]

event that handles received presence stanzas

Note:
This handler does not get notified for subscription stanzas, on_subscription_stanza() is used for them instead.

The default implementation is to bounce the stanza

Parameters:
pthe received message stanza
Returns:
should normally return r_DONE if the stanza has been handled (for other possible values see the result type)

References bounce_stanza(), and r_DONE.

Referenced by on_stanza_packet().

event that handles received packets, that contain a normal stanza (type p_ROUTE)

The default implementation is to bounce the packet

Parameters:
dpthe packet containing the stanza
Returns:
should normally return r_DONE if the packet has been handled (for other possible values see the result type)

References deliver_fail(), and r_DONE.

Referenced by on_packet().

event that handles received packets, that contain a normal stanza (type p_NORM)

The default implementation of this handler is to forward the stanza to the relevant handler: on_message_stanza(), on_presence_stanza(), on_iq_stanza(), or on_subscription_stanza()

Parameters:
dpthe packet containing the stanza
Returns:
should normally return r_DONE if the packet has been handled (for other possible values see the result type)

References deliver_fail(), jpacket_new(), on_iq_stanza(), on_message_stanza(), on_presence_stanza(), on_subscription_stanza(), r_DONE, and dpacket_struct::x.

Referenced by on_packet().

result xmppd::instance_base::on_subscription_stanza ( jpacket  p) [protected, virtual]

event that handles received subscription stanzas

The default implementation is to bounce the stanza

Parameters:
pthe received message stanza
Returns:
should normally return r_DONE if the stanza has been handled (for other possible values see the result type)

References r_DONE, and xmlnode_free().

Referenced by on_stanza_packet().

result xmppd::instance_base::on_xdb_packet ( dpacket  dp) [protected, virtual]

event that handles received packets, that contain a normal stanza (type p_XDB)

The default implementation is to bounce the packet

Parameters:
dpthe packet containing the stanza
Returns:
should normally return r_DONE if the packet has been handled (for other possible values see the result type)

References deliver_fail(), and r_DONE.

Referenced by on_packet().

void xmppd::instance_base::set_heartbeat_interval ( int  interval) [protected]

(re)set the heartbeat interval

If no heartbeat has been registered for this instance yet, it gets registered

Parameters:
intervalthe interval in seconds how often the on_heartbeat() event should be fired, 0 for disabling heartbeat again

References register_beat().


The documentation for this class was generated from the following files: