setCFCMethod

Description

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

Category

Event Gateway Development

Syntax

void setCFCMethod(String method)

See also

getCFCMethod, setCFCPath, setCFCTimeout, CFML CFEvent structure, CFEvent 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.