Defining SMS Gateways


Like our IM application, before you can actually use it or even begin testing it, you will need a configuration file, a stub CFC and to create a gateway instance. The SMS gateway is fairly straightforward in the fact that it only has one method that needs to be exposed, the onIncomingMessage() method that listens for inbound SMS messages.

Listing 32.6. sms_stub.cfcEmpty SMS Gateway CFC
 <cfcomponent>    <cffunction name="onIncomingMessage" hint="Standard message from SMS users">       <cfargument name="CFEvent" type="struct" required="YES">     </cffunction>  </cfcomponent> 

To keep things relatively simple we will be using the inbuilt test SMS server, so go and grab the default configuration file from your ColdFusion installation. It is found in the cf_root\WEB-INF\cfusion\gateway\config directory on J2EE configurations, and cf_root\gateway\config directory on standard server configurations.

Unlike the IM configuration file there are a lot of different settings that you will need for your configuration file, the most basic of which are the connection details to the SMSC server. These are the basic settings but you will want to go and copy the default settings from within your ColdFusion installation as there are many options that you can tweak if needed. You will find the default configuration file in the cf_root\WEB-INF\cfusion\gateway\config directory on J2EE configurations, and cf_root\gateway\config directory on standard server configurations. Such as:

 # SMSC server details ip-address=127.0.0.1 port=7901 system-id=cf password=cf # Source address for this client source-ton=1 source-npi=1 source-address=5551212 # The address range this smpp client will serve # Generally the same as your source address addr-ton=1 addr-npi=1 address-range=5551212 #this is the number of messages per second that the gateway is permitted to send. message-rate=100.0 # network communication mode mode= synchronous # network retry settings network-retry=no transient-retry=no 

Unlike the IM gateway configuration file, many of these settings are foreign to many ColdFusion developers. The first group, the SMSC server details are fairly straightforward, they are just the IP address, the port and the username and password that will be supplied by your SMSC provider.

The second group refers to the source phone details that your gateway will be sending messages as and the range of addresses that this SMPP client can serve.

Lastly there are the actual connection settings, including the amount of messages this gateway will support per second, and the retry settings on message failure. The most important setting in this section is the communication mode. The default is synchronous communication mode, in this mode the gateway will wait for a response from the SMSC with the message ID of the message so you can track delivery reports. If the gateway is set to use asynchronous mode, the ColdFusion gateway will not wait for a response from the SMSC and thus can send messages faster but you will lose the ability to track receipt of messages.

TIP

Be sure to include the rest of the default settings in your SMS configuration file or your gateway may not start.


Now we are going to extend our helpdesk application to use SMS to communicate with the various helpdesk staff. We are going to call our gateway instance "Helpdesk", and create a gateway instance called "Helpdesk5551212". We have added the phone number that the gateway uses to the end of the instance name to make it nice and easy to identify which gateway uses which phone number. When you create your gateway, rename the stub cfc to sms.cfc so it is clear that this the file that is actually in use.



Advanced Macromedia ColdFusion MX 7 Application Development
Advanced Macromedia ColdFusion MX 7 Application Development
ISBN: 0321292693
EAN: 2147483647
Year: 2006
Pages: 240
Authors: Ben Forta, et al

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net