Description

Sets the name of the CFC method that processes an incoming message.

Category

Event Gateway Development

Syntax

void setCFCMethod(String method)

See also

getCFCMethodsetCFCPathsetCFCTimeoutCFML CFEvent structureCFEvent class in the Developing ColdFusion Applications

Parameters

Parameter

Description

method

The method in the listener CFC that ColdFusion calls to process this event. If you do not use this method in your gateway, ColdFusion invokes the onIncomingMessage method.

Usage

Gateways that use a single CFC listener method do not need to use this method if the listener CFC method is named onIncomingMessage. For the sake of consistency, Adobe recommends that any event gateway with a single listener not override this default. A gateway, such as the ColdFusion XMPP gateway, that uses different listener methods for different message types uses this method to identify the destination method.

Example

The following example code comes from the ColdFusion XMPP gateway incoming message handler. It creates a CFEvent object and sets the method that handles tests based on the message type.

CFEvent cfmsg = new CFEvent(gatewayID);
cfmsg.setOriginatorID(sender);
cfmsg.setGatewayType(gatewayType);
if(messageType == IMessage.IM)
{
// default for normal messages
cfmsg.setCfcMethod(onIncomingMessageFunction);
}
//if the message is an authorization request
else if(messageType == IMessage.AUTH_REQUEST)
{
cfmsg.setCfcMethod(onAddBuddyRequestFunction);
message = "Requesting authorization to add '" + recipient + "' to '"
+ sender + "' buddy list and view '" + recipient + "' presence.";
} // Code snipped here for brevity.

 

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy