| GSM-SMS documentation | Contained in the GSM-SMS distribution. |
GSM::SMS::Transport::Transport - Base class for transports
This class is a base class for all transports, i.e. all transports must inherit from this class.
$transport->has_valid_route( $msisdn );
$PDU = $transport->receive();
Johan Van den Brande <johan@vandenbrande.com>
| GSM-SMS documentation | Contained in the GSM-SMS distribution. |
package GSM::SMS::Transport::Transport; use strict; use vars qw( $VERSION $AUTOLOAD ); use Carp; $VERSION = "0.161";
sub new { my ($proto, %args) = @_; my $class = ref($proto) || $proto; my $self = { _name => $args{-name} || croak("missing name"), _originator => $args{-originator} || 'GSM::SMS', _match => $args{-match} || croak("missing match regexp") }; bless($self, $class); return $self; }
sub has_valid_route { my ($self, $msisdn) = @_; foreach my $route ( split /,/, $self->get_match() ) { return -1 if $msisdn =~ /$route/; } return 0; }
sub METHOD::ABSTRACT { my ($self) = @_; my $object_class = ref($self); my ($file, $line, $method) = (caller(1))[1..3]; die "Call to abstract method ${method} at $file, line $line\n"; }
sub send { ABSTRACT METHOD @_ }
sub receive { ABSTRACT METHOD @_ }
sub close { ABSTRACT METHOD @_ }
sub ping { ABSTRACT METHOD @_ }
sub get_info { ABSTRACT METHOD @_ }
sub DESTROY {}
sub AUTOLOAD { my ($self, $newval) = @_; # Handle get_... method $AUTOLOAD =~ /.*::get(_\w+)/ and $self->_accessible($1, 'read') and return $self->{$1}; # Handle set_... method $AUTOLOAD =~ /.*::set(_\w+)/ and $self->_accessible($1, 'write') and do { $self->{$1} = $newval; return; }; # Oops ... a mistake croak "No such method: $AUTOLOAD"; } 1; __END__