User Guide

Table Of Contents
Building an event gateway 1099
Synchronous mode The method does not return until the message is delivered to the SMSC,
or an error occurs.
This way, an SMS application can get a message ID for later use, such as to compare with a
message receipt.
Example outgoingMessage method
The following outgoingMessage method is similar to the version in the SocketGateway class. It
does the following:
1.
Gets the contents of a MESSAGE field of the Data Map returned by the CFEvent class
getData
method.
2.
Gets the destination from an outDestID field in the data Map.
3.
Uses the destination’s socket server thread to write the message.
public String outgoingMessage(coldfusion.eventgateway.CFEvent cfmsg) {
String retcode="ok";
// Get the table of data returned from the event handler
Map data = cfmsg.getData();
String message = (String) data.get("MESSAGE");
// Find the right socket to write to from the socketRegistry hashtable
// and call the socket thread’s writeoutput method.
// (Get the destination ID from the data map.)
if (data.get("outDestID") != null)
((SocketServerThread)socketRegistry.get(data.get("outDestID"))).
writeOutput(message);
else {
System.out.println("cannot send outgoing message. OriginatorID is not
available.");
retcode="failed";
}
return retcode;
}
Logging events and using log files
The
GatewayServices.getLogger method returns an instance of the
coldfusion.eventgateway.Logger class that you can use to log messages to a file in the ColdFusion
logs directory. (You set this directory on the ColdFusion MX Administrator Logging Settings
page.) The method can take no parameter, or one parameter:
The default GatewayServices.getLogger method uses the eventgateway.log file.
Optionally, you can specify a log filename, without the .log extension or directory path.
The following example tells ColdFusion to log messages from the gateway to the mygateway.log
file in the ColdFusion logs directory:
coldfusion.eventgateway.Logger log =
getGatewayServices().getLogger(“mygateway“);