NAME
Sprocket::Plugin - Base class for Sprocket plugins
SYNOPSIS
use Sprocket qw( Plugin );
use base qw( Sprocket::Plugin );
sub new {
shift->SUPER::new(
name => 'MyPlugin',
@_
);
}
sub as_string {
__PACKAGE__;
}
...
ABSTRACT
This is a base class for Sprocket plugins. It provides several default methods for easy plugin implementation.
NOTES
A plugin can define any of the methods below. All are optional, but a plugin should have a conncted and a recieve method for it to function. See the Sprocket site for examples. http://sprocket.cc/ Plugins should use the template in the SYNOPSIS.
METHODS
Server Methods
These are methods that can be defined in a plugin for Sprocket server instances
- local_accept
-
Called with ( $self, $server, $con, $socket ) Defining this method is optional. The default behavior is to accept the connection. You can call $con->reject() or $con->accept() to reject or accept a connection. You can also call $self->take_connection( $con ); in this phase. See Sprocket::Connection for more information on the accept and reject methods.
- local_connected
-
Called with ( $self, $server, $con, $socket ) This is the last chance for a plugin to take a connection with $self->take_connection( $con ); You should apply your filters for the connection in this method. See Sprocket::Connection for details on how to access the connection's filters.
- local_receive
-
Called with ( $self, $server, $con, $data ) $data is the data from the filter applied to the connection.
- local_disconnected
-
Called with ( $self, $server, $con, $error ) If error is true, then $operation, $errnum, and $errstr will also be defined after $error. If a connection was closed with $con->close() then $error will be false. If a connection was closed remotely but without an error then $error will be true, but $errnum will be 0. For more details, see ErrorEvent in POE::Wheel::ReadWrite.
Client Methods
These are methods that can be defined in a plugin for Sprocket client instances
- remote_accept
-
Why is there an accept method for client connections?! Well, good question. This method is here to allow you to set the filters and blocksize using the $con-accept method. See Sprocket::Connection
See local_accept.
- remote_connected
-
See local_connected.
- remote_receive
-
See local_receive.
- remote_disconnected
-
See local_disconnected. You can call $con->reconnect() to attempt to reconnect to the original host.
- remote_connect_error
-
Called with ( $self, $client, $con, $operation, $errnum, $errstr ) See ErrorEvent in POE::Wheel::ReadWrite. This is called when a connection couldn't be established.
- remote_resolve_failed
-
Called with ( $self, $client, $con, $response_error, $response_obj ) Sprocket uses POE::Component::DNS internally. Connections to ip's are not resolved.
SEE ALSO
Sprocket, Sprocket::Connection, Sprocket::AIO
AUTHOR
David Davis <xantus@cpan.org>
COPYRIGHT AND LICENSE
Copyright 2006-2007 by David Davis
See Sprocket for license information.