#################### main pod documentation begin ################### =head1 NAME Zymonic::Decryptor::Message - Zymonic Decryptor base module. =head1 SYNOPSIS This is a simple 'base' class for writing decryptor message handlers - on its own it simply 'pings'. =head1 DESCRIPTION This is a Message class to allow the decryptor to handle messages in a 'polymorphic' way it is based on Zymonic::Base, not Zymonic::Decryptor... =head1 USAGE The base class acts like a ping - to create your own message, sub-class this object and override the respond method. =head1 BUGS None we're aware of... =head1 SUPPORT As in the license, Zymonic is provided without warranty or support unless purchased separately, however... If you email zymonic-support@zednax.com your issue will be noted and may receive a response. For security issues, please contact zymonic-security@zednax.com and someone will respond within 8 working hours. =head1 AUTHOR Alex Masidlover et al. CPAN ID: MODAUTHOR Zednax Limited alex.masidlover@zednax.com http://www.zednax.com =head1 COPYRIGHT This program is free software licensed under the... Zymonic Public License 1.0 The full text of the license can be found in the LICENSE file included with this module. Other licenses may be acceptable if including parts of Zymonic in larger projects, please contact Zednax for details. =head1 SEE ALSO perl(1). =cut #################### main pod documentation end ################### package Zymonic::Decryptor::Message; use strict; use warnings; BEGIN { use Exporter (); use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); $VERSION = '0.01'; @ISA = qw(Exporter); #Give a hoot don't pollute, do not export more than needed by default @EXPORT = qw(); @EXPORT_OK = qw(); %EXPORT_TAGS = (); } use base 'Zymonic::Base'; use Zymonic::Utils qw(deep_replace_card_numbers); #################### subroutine header begin #################### =head2 respond Usage : my $response = $mh->repsond($in) Purpose : This is the response handler method for decryptor messages. Returns : a response hashref Argument : a message hashref Throws : nothing Comment : The 'base' response is just a ping... See Also : =cut #################### subroutine header end #################### sub respond { my $self = shift; my $in = shift; if ( $in->{messagetype} ) { $self->{decryptor_server} ->connection_log( 'In base Message class with a messagetype - do perl -e "use Zymonic::Decryptor::Message::' . $in->{messagetype} . ';" to check installation if you were not expecting this message.' ); } $self->{decryptor_server}->connection_log('Sleeping'); sleep(1); $self->{decryptor_server}->connection_log( 'Responding to a ping of ' . ( $in->{ping} || '' ) ); return { incoming_was => { data => ( 'X' x ( length( $in->{data} ) - 4 ) ) . substr( $in->{data}, -4 ) }, 'content' => 'PING!', }; } #################### subroutine header begin #################### =head2 weaken_refs Usage : $self->weaken_refs Purpose : Called to weaken refs on the current object. Returns : nothing Argument : optional array ref of names of attributes to weaken/not weaken. Throws : Comment : Weakens decryptor_server ref. See Also : =cut #################### subroutine header end #################### sub weaken_refs { my $self = shift; my $weaken = shift || []; my $dont_weaken = shift || []; push( @{$weaken}, 'decryptor_server' ); $self->SUPER::weaken_refs( $weaken, $dont_weaken ); } 1;