NAME
SMS::Handler - Base class for processing SMS messages in sms-agent
SYNOPSIS
use SMS::Handler;
DESCRIPTION
This module implements the base implementation (virtual class) for a class that processes SMS messages.
SMS messages will be passed as a hash reference, which contains the following keys.
source_addr_ton
-
The TON for the source address of the SMS.
source_addr_npi
-
The NPI for the source address of the SMS.
source_addr
-
The source address.
dest_addr_ton
-
The TON for the destination address of the SMS.
dest_addr_npi
-
The NPI for the destination address of the SMS.
destination_addr
-
The destination address.
short_message
-
The actual SMS.
The hash reference will be passed to a method called ->handle
, which derived classes are expected to implement. This method must return the following OR-ed values to indicate the required action on the SMS.
SMS_CONTINUE
-
Causes the next handler in sequence to be tried.
SMS_STOP
-
Tells
sms-agent
to stop trying to look for another handler to process the SMS. If this value is not ORed in the return of the method, the next handler in sequence is tried. SMS_DEQUEUE
-
Tells
sms-agent
to remove the SMS from any queue it may have the message in. Normally this is done on success.
Normally, you want to use SMS_STOP
whenever you produce a final answer. You probably want to add SMS_DEQUEUE
too.
Sample Event Loop
Derived classes should be used through an event loop as depicted below:
while (1)
{
my $sms = wait_sms_hash();
for my $h (@List_Of_Handlers)
{
my $ret = $h->handle($sms);
if ($ret & SMS_DEQUEUE)
{
# Get rid of this SMS.
}
last if ($ret & SMS_STOP);
}
}
Where wait_sms_hash()
should produce a hash with the appropiate key / value pairs. Tipically, either Net::SMPP::XML
or Net::SMPP
1.04 or greater should be of great help here if you want to fetch and store Net::SMPP::PDU
s in some form of stable storage or queue.
EXPORT
None by default.
HISTORY
$Id: Handler.pm,v 1.7 2003/01/14 20:32:34 lem Exp $
LICENSE AND WARRANTY
This code comes with no warranty of any kind. The author cannot be held liable for anything arising of the use of this code under no circumstances.
This code is released under the terms and conditions of the GPL. Please see the file LICENSE that accompains this distribution for more specific information.
This code is (c) 2002 Luis E. Muñoz.
AUTHOR
Luis E. Muñoz <luismunoz@cpan.org>
SEE ALSO
sms-agent, Net::SMPP::XML, Net::SMPP, perl(1).
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 191:
Non-ASCII character seen before =encoding in 'Muñoz.'. Assuming CP1252