Agent-TCLI
view release on metacpan or search on metacpan
lib/Agent/TCLI/Parameter.pm view on Meta::CPAN
Typically each Package will have a field defined with a standard
accessor/mutator that represents the default value to be used for the
parameter when the command the command is called. This field can be
manually defined in the Package, or it can be autocreated upon parameter
loading within the Package. If necessary, the class filed may be used to
set the Object::InsideOut type to be used for the field.
The reason for the use of Parameter and Command objects is to push a Package
to be as data driven as possible, with only the only code being the actual
command logic. It was decided that it would be best to evolve towards that
goal, rather than try to get it right from the outset. So what you see what
you get.
=cut
use warnings;
use strict;
use Object::InsideOut qw(Agent::TCLI::Base);
lib/Agent/TCLI/Request.pm view on Meta::CPAN
=cut
my @id :Field
:All('id');
=item args
The request's arguments as parsed into an array. Usually built by the
Agent::TCLI::Control, but may be set up externally as well.
B<args> will only accept ARRAY type values. Since B<args> is an array, it is
often best use one of the mutator methods listed below.
=cut
my @args :Field
:All('args')
:Type('ARRAY' );
=item command
An array containing the prmoinent verb for this request, followed by the
rest of the context the command was issued in reversed.
B<command> will only accept ARRAY type values. Since B<command> is an array,
it is often best use one of the mutator methods listed below.
=cut
my @command :Field
:All('command')
:Type('ARRAY' );
=item sender
The POE session making the request, so that the response can be returned
properly. It is also the Tranport used when going between agents.
lib/Agent/TCLI/Request.pm view on Meta::CPAN
return $response;
}
=item Respond ( <poe_kernel>, <text> [, <code>]) or ( <poe_kernel>, <response obj> )
Respond is the proper way to return a response to a request. It requires a
reference to the poe_kernel as the first parameter. The second parameter
may be either some text for the response or a Response object. The third
parameter is the resposne code. If not provided, it defaults to 200. While not
required, it is best to always fill in the response code. The response code
will be ignored if a Response object is provided.
=cut
sub Respond {
# using Respond to return anything. That way it will
# be easier to change/override how to return later on,
# and call from the middle of a method.
my ($self, $kernel, $txt, $code) = @_;
$self->Verbose("Respond: id(".$id[$$self].") dump(".$self->dump(1),5);
lib/Agent/TCLI/Transport/Base.pm view on Meta::CPAN
=item PackRequest
This object method is used by transports to prepare a request for transmssion.
Currently the code is taking a lazy approach and using Perl's YAML and OIO->dump to
safely freeze and thaw the request/responses for Internet transport.
By standardizing these routines in the Base class, more elegant methods
may be transparently enabled in the future.
=cut
# TODO review XEP on this, esp version numbers and best practices.
sub PackRequest {
my ($self, $request) = @_;
my $dump = $request->dump();
# Take out the Base to save space since we're ignore this at the other end.
delete $dump->[1]{'Agent::TCLI::Base'};
my $packed_request = freeze($dump);
return($packed_request);
lib/Agent/TCLI/Transport/Base.pm view on Meta::CPAN
It will return either an existing control or create a new one. All
requests for a control are authenticated. Thus when a Transport recieves
a new request, user priviledges are rechecked against the latest database
if GetControl is used to obtain the Control.
The control_id is a unique ID for the transport to use to identify the control.
This is useful in situations where a user may have more than one control
active at a time.
The user must be a Agent::TCLI::User object. The protocol should be one
that the Transport supports and will be matched for authentication.
A transport may optionally override the user_auth level. This would be best
used to drop to a read only transport, but currently the direction is not
enforced.
=cut
sub GetControl {
my ($self, $control_id, $user, $user_protocol, $user_auth ) = @_;
$self->Verbose($self->alias.":GetControl: id(".$control_id.") \n");
my $user_id = ref($user) =~ /User/i ? $user->id : $user;
( run in 0.987 second using v1.01-cache-2.11-cpan-4e96b696675 )