
POE::Component::Server::IRC::Backend - A POE component class that provides network connection abstraction for POE::Component::Server::IRC

package MyIRCD;
use strict;
use warnings;
use base 'POE::Component::Server::IRC::Backend';
sub spawn {
my ($package, %args) = @_;
my $self = $package->create(prefix => 'ircd_', @_);
# process %args ...
return $self;
}

POE::Component::Server::IRC::Backend - A POE component class that provides network connection abstraction for POE::Component::Server::IRC. It uses a plugin system. See POE::Component::Server::IRC::Plugin for details.

createReturns an object. Accepts the following parameters, all are optional:
raw_events;If the component is created from within another session, that session will be automagcially registered with the component to receive events and get an 'ircd_backend_registered' event.

shutdownTakes no arguments. Terminates the component. Removes all listeners and connectors. Disconnects all current client and server connections. This is a shorthand for $ircd->yield('shutdown').
session_idInherited from POE::Component::Syndicator
Takes no arguments. Returns the ID of the component's session. Ideal for posting events to the component.
session_aliasInherited from POE::Component::Syndicator
Takes no arguments. Returns the session alias that has been set through create's 'alias' argument.
yieldInherited from POE::Component::Syndicator
This method provides an alternative object based means of posting events to the component. First argument is the event to post, following arguments are sent as arguments to the resultant post.
callInherited from POE::Component::Syndicator
This method provides an alternative object based means of calling events to the component. First argument is the event to call, following arguments are sent as arguments to the resultant call.
delayInherited from POE::Component::Syndicator
This method provides a way of posting delayed events to the component. The first argument is an arrayref consisting of the delayed command to post and any command arguments. The second argument is the time in seconds that one wishes to delay the command being posted.
Returns an alarm ID that can be used with delay_remove to cancel the delayed event. This will be undefined if something went wrong.
delay_removeInherited from POE::Component::Syndicator
This method removes a previously scheduled delayed event from the component. Takes one argument, the alarm_id that was returned by a delay method call.
Returns an arrayref that was originally requested to be delayed.
send_eventInherited from POE::Component::Syndicator
Sends an event through the component's event handling system. These will get processed by plugins then by registered sessions. First argument is the event name, followed by any parameters for that event.
send_event_nextInherited from POE::Component::Syndicator
This sends an event right after the one that's currently being processed. Useful if you want to generate some event which is directly related to another event so you want them to appear together. This method can only be called when POE::Component::IRC is processing an event, e.g. from one of your event handlers. Takes the same arguments as send_event.
send_event_nowInherited from POE::Component::Syndicator
This will send an event to be processed immediately. This means that if an event is currently being processed and there are plugins or sessions which will receive it after you do, then an event sent with send_event_now will be received by those plugins/sessions before the current event. Takes the same arguments as send_event.
raw_eventsIf called with a true value, raw events (ircd_raw_input and ircd_raw_output) will be enabled.
antifloodTakes two arguments, a connection id and true/false value. If value is specified antiflood protection is enabled or disabled accordingly for the specified connection. If a value is not specified the current status of antiflood protection is returned. Returns undef on error.
compressed_linkTakes two arguments, a connection id and true/false value. If a value is specified, compression will be enabled or disabled accordingly for the specified connection. If a value is not specified the current status of compression is returned. Returns undef on error.
disconnectRequires on argument, the connection id you wish to disconnect. The component will terminate the connection the next time that the wheel input is flushed, so you may send some sort of error message to the client on that connection. Returns true on success, undef on error.
connection_existsRequires one argument, a connection id. Returns true value if the connection exists, false otherwise.
connection_infoTakes one argument, a connection_id. Returns a list consisting of: the IP address of the peer; the port on the peer; our socket address; our socket port. Returns undef on error.
my ($peeraddr, $peerport, $sockaddr, $sockport) = $ircd->connection_info($conn_id);
add_denialTakes one mandatory argument and one optional. The first mandatory argument is a Net::Netmask object that will be used to check connecting IP addresses against. The second optional argument is a reason string for the denial.
del_denialTakes one mandatory argument, a Net::Netmask object to remove from the current denial list.
deniedTakes one argument, an IP address. Returns true or false depending on whether that IP is denied or not.
add_exemptionTakes one mandatory argument, a Net::Netmask object that will be checked against connecting IP addresses for exemption from denials.
del_exemptionTakes one mandatory argument, a Net::Netmask object to remove from the current exemption list.
exemptedTakes one argument, an IP address. Returns true or false depending on whether that IP is exempt from denial or not.
pipelineInherited from Object::Pluggable
Returns the Object::Pluggable::Pipeline object.
plugin_addInherited from Object::Pluggable
Accepts two arguments:
The alias for the plugin The actual plugin object Any number of extra arguments
The alias is there for the user to refer to it, as it is possible to have multiple plugins of the same kind active in one Object::Pluggable object.
This method goes through the pipeline's push() method, which will call $plugin->plugin_register($pluggable, @args).
Returns the number of plugins now in the pipeline if plugin was initialized, undef/an empty list if not.
plugin_delInherited from Object::Pluggable
Accepts the following arguments:
The alias for the plugin or the plugin object itself Any number of extra arguments
This method goes through the pipeline's remove() method, which will call $plugin->plugin_unregister($pluggable, @args).
Returns the plugin object if the plugin was removed, undef/an empty list if not.
plugin_getInherited from Object::Pluggable
Accepts the following arguments:
The alias for the plugin
This method goes through the pipeline's get() method.
Returns the plugin object if it was found, undef/an empty list if not.
plugin_listInherited from Object::Pluggable
Takes no arguments.
Returns a hashref of plugin objects, keyed on alias, or an empty list if there are no plugins loaded.
plugin_orderInherited from Object::Pluggable
Takes no arguments.
Returns an arrayref of plugin objects, in the order which they are encountered in the pipeline.
plugin_registerInherited from Object::Pluggable
Accepts the following arguments:
The plugin object The type of the hook (the hook types are specified with _pluggable_init()'s 'types') The event name[s] to watch
The event names can be as many as possible, or an arrayref. They correspond to the prefixed events and naturally, arbitrary events too.
You do not need to supply events with the prefix in front of them, just the names.
It is possible to register for all events by specifying 'all' as an event.
Returns 1 if everything checked out fine, undef/an empty list if something is seriously wrong.
plugin_unregisterInherited from Object::Pluggable
Accepts the following arguments:
The plugin object The type of the hook (the hook types are specified with _pluggable_init()'s 'types') The event name[s] to unwatch
The event names can be as many as possible, or an arrayref. They correspond to the prefixed events and naturally, arbitrary events too.
You do not need to supply events with the prefix in front of them, just the names.
It is possible to register for all events by specifying 'all' as an event.
Returns 1 if all the event name[s] was unregistered, undef if some was not found.

These are POE events that the component will accept:
registerInherited from POE::Component::Syndicator
Takes N arguments: a list of event names that your session wants to listen for, minus the irc_ prefix.
$ircd->yield('register', qw(connected disconnected));
The special argument 'all' will register your session for all events. Registering will generate an ircd_registered event that your session can trap.
unregisterInherited from POE::Component::Syndicator
Takes N arguments: a list of event names which you don't want to receive. If you've previously done a register for a particular event which you no longer care about, this event will tell the component to stop sending them to you. (If you haven't, it just ignores you. No big deal.)
If you have registered with 'all', attempting to unregister individual events such as 'connected', etc. will not work. This is a 'feature'.
add_listenerTakes a number of arguments. Adds a new listener.
del_listenerTakes one of the following arguments:
The listener will be deleted. Note: any connected clients on that port will not be disconnected.
add_connectorTakes two mandatory arguments, 'remoteaddress' and 'remoteport'. Opens a TCP connection to specified address and port.
send_outputTakes a hashref and one or more connection IDs.
$ircd->yield(
'send_output',
{
prefix => 'blah!~blah@blah.blah.blah',
command => 'PRIVMSG',
params => ['#moo', 'cows go moo, not fish :D']
},
@list_of_connection_ids,
);
shutdownInherited from POE::Component::Syndicator
Takes no arguments. Terminates the component. Removes all listeners and connectors. Disconnects all current client and server connections.

These following events are sent to interested sessions.
ircd_registeredInherited from POE::Component::Syndicator
ARG0: the component's object;ircd_connectionARG0: the conn id;ARG1: their ip address;ARG2: their tcp port;ARG3: our ip address;ARG4: our socket port;ARG5: a boolean indicating whether the client needs to be authedircd_auth_doneARG0, the connection id;ARG1, a HASHREF with the following keys: 'ident' and 'hostname';ircd_listener_addadd_listener call;ARG0, the listening port;ARG1, the listener id;ARG2, the listening address;ircd_listener_deldel_listener call;ARG0, the listening port;ARG1, the listener id;ARG2, the listener address;ircd_listener_failureARG0, the listener id;ARG1, the name of the operation that failed;ARG2, numeric value for $!;ARG3, string value for $!;ARG4, the port it tried to listen on;ARG5, the address it tried to listen on;ircd_socketerradd_connector callARG0, a HASHREF containing the params that add_connector() was called with;ARG1, the name of the operation that failed;ARG2, numeric value for $!;ARG3, string value for $!;ircd_connectedARG0, the connection id;ARG1, their ip address;ARG2, their tcp port;ARG3, our ip address;ARG4, our socket port;ARG5, the peer's name;ircd_connection_floodARG0, the connection id;ircd_connection_idleARG0, the connection id;ARG1, the number of seconds period we consider as idle;ircd_compressed_connARG0, the connection id;ircd_cmd_*ARG0, the connection id;ARG1, a HASHREF containing the output record from POE::Filter::IRCD:
{
prefix => 'blah!~blah@blah.blah.blah',
command => 'PRIVMSG',
params => [ '#moo', 'cows go moo, not fish :D' ],
raw_line => ':blah!~blah@blah.blah.blah.blah PRIVMSG #moo :cows go moo, not fish :D'
}
ircd_raw_inputARG0, the connection id;ARG1, the raw line of inputircd_raw_outputARG0, the connection id;ARG1, the raw line of outputircd_disconnectedARG0, the connection id;ARG1, the error or reason for disconnection;ircd_shutdownInherited from POE::Component::Syndicator
shutdownARG0: the session ID of the requesting componentircd_delay_setInherited from POE::Component::Syndicator
delay methodARG0: the alarm id which can be used later with delay_removeARG1..$#_: subsequent arguments are those which were passed to delayircd_delay_removedInherited from POE::Component::Syndicator
ARG0: the alarm id which was removedARG1..$#_: subsequent arguments are those which were passed to delayircd_plugin_addInherited from Object::Pluggable
ARG0: the plugin aliasARG1: the plugin objectircd_plugin_delInherited from Object::Pluggable
ARG0: the plugin aliasARG1: the plugin objectircd_plugin_errorInherited from Object::Pluggable
ARG0: the error messageARG1: the plugin aliasARG2: the plugin object
Chris 'BinGOs' Williams

Copyright © Chris Williams
This module may be used, modified, and distributed under the same terms as Perl itself. Please see the license that came with your Perl distribution for details.
