getData

Description

Returns the data Map that contains the message contents and other gateway-specific information.

Category

Event Gateway Development

Syntax

Map getData()

See also

setData, CFML CFEvent structure, CFEvent class in the Developing ColdFusion Applications

Returns

The event data structure, or null. This structure includes the message contents being passed by the gateway and any other gateway-specific information.

Usage

The contents of the data Map depends on the event gateway type. Typical fields include the message contents, originator ID, destination ID, and if a gateway (such as the ColdFusion SMS gateway) supports multiple commands, the command.

Note: The returned Map object has case-insensitive keys.

Example

The following outgoingMessage method from the SocketGateway example gateway gets the message contents from the CFEvent data field of an outgoing message. If the CFEvent object does not include an OriginatorID field, it also tries to get the originator ID from the data field.

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 
    if (cfmsg.getOriginatorID() != null) 
        ((SocketServerThread)socketRegistry.get(cfmsg.getOriginatorID())). 
            writeOutput(message); 
    else if (data.get("OriginatorID") != null) 
        ((SocketServerThread)socketRegistry.get(data.get("OriginatorID"))). 
            writeOutput(message); 
    else { 
        System.out.println("cannot send outgoing message. OriginatorID is not 
            available."); 
            retcode="failed"; 
    } 
    return retcode; 
}