| GSM-SMS documentation | Contained in the GSM-SMS distribution. |
GSM::SMS::Transport::File - Dump PDU strings to files
Dump PDU strings to a file. Can be used as a debugging means, to catch PDU messages or used with a pickup daemon that reads outgoing messages from a directory.
All outgoing SMS messages are dumped in a unique file in a specified directory.
my $tfile = GSMS::SMS::Transport::File->new(
-name => $name_of_transport,
-match => $matching_regex_for_allowed_msisdn,
-out_directory => $file_to_dump_PDU_to
);
Johan Van den Brande <johan@vandenbrande.com>
| GSM-SMS documentation | Contained in the GSM-SMS distribution. |
package GSM::SMS::Transport::File;
use strict; use vars qw( $VERSION $AUTOLOAD ); use base qw( GSM::SMS::Transport::Transport ); use Carp; use Log::Agent; use File::Temp qw( tempfile ); $VERSION = "0.161"; { my %_attrs = ( _name => 'read', _match => 'read/write', _out_directory => 'read/write' ); sub _accessible { my ($self, $attr, $mode) = @_; $_attrs{$attr} =~ /$mode/ } }
sub new { my ($proto, %args) = @_; my $class = ref($proto) || $proto; logdbg "debug", "$class constructor called"; my $self = $class->SUPER::new(%args); $self->{_out_directory} = $args{-out_directory} || croak( "missing out_directory"); bless $self, $class; logdbg "debug", "GSM::SMS::Transport::File started"; return $self; }
sub send { my($self, $msisdn, $p) = @_; chomp($p); my ($fh, $filename) = tempfile( DIR => $self->get_out_directory() ); logdbg "debug", "Saving message in $filename"; print $fh "$msisdn|$p\n"; close $fh; return 0; }
sub receive { my ($self, $pduref) = @_; return -1; }
sub init { my ($self, $config) = @_; return 0; }
sub close { my ($self) =@_; }
sub ping { my ($self) = @_; return "OK"; }
sub get_info { my ($self) = @_; my $revision = '$Revision: 1.2 $'; my $date = '$Date: 2003/01/11 14:16:34 $'; print <<EOT; File transport $VERSION Revision: $revision Date: $date EOT }
1;