User Guide

Table Of Contents
1030 Chapter 42: Using Event Gateways
Sending information to the event gateway
A ColdFusion application can send an outgoing message to the event gateway in either of the
following ways:
In a cfreturn tag in the listener CFC’s listener method
By calling the ColdFusion SendGatewayMessage function
The first method is useful to automatically respond to incoming messages. Some complex
applications that respond to incoming messages might use the
SendGatewayMessage function
either in place or in addition to the return value.
Some event gateway types also use a GatewayHelper object to send information to external
resources. For example, the ColdFusion MX XMPP and Lotus Sametime instant messaging event
gateways provide a GatewayHelper object that can manage buddy lists, and set configuration and
status information on the instant messaging server. For more information on the GatewayHelper
object, see “Using the GatewayHelper object” on page 1036. For more information on the instant
messaging GatewayHelper object, see “Sample IM message handling application” on page 1054.
The example code in “Example event gateway CFC” on page 1034 shows the use of a listener
return value, and indicates how event gateways can require different data in the return structure to
send equivalent messages.
Developing event gateway listener CFCs
The listener CFC responds to event gateway messages. The listener CFC uses, at a minimum, the
following basic software elements:
One or more listener methods
CFEvent structures that contain the messages
Listener CFCs can use ColdFusion persistent scopes to store data that needs to be preserved over
multiple CFC invocations or shared with other CFML elements.
Listener methods
The ColdFusion event gateway service calls one or more listener methods in the CFC to process
incoming messages. The number of listener methods that you must write and their names
depends on the event gateway. For example, the ColdFusion SMS event gateway requires a single
listener method, which is typically named
onIncomingMessage. (You can change the SMS event
gateway listener method name in the event gateway configuration file.) The ColdFusion XMPP
IM event gateway expects the listener CFC to have five methods:
onIncomingMessage,
onAddBuddyRequest, onAddBuddyResponse, onBuddyStatus, and onIMServerMessage. By
default, if the event gateway does not specify the method name, ColdFusion calls the listener
CFC’s
onIncomingMessage method. For the sake of consistency, Macromedia recommends that
any event gateway with a single listener method use the
onIncomingMessage method.