getOriginatorID

Description

Identifies the originator of an incoming message. Some gateway types also use this field for the destination of an outgoing message.

Category

Event Gateway Development

Syntax

String getOriginatorID()

See also

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

Returns

The protocol-specific identifier of the message originator, or null.

Example

The outgoingMessage method of the SocketGateway example gateway uses the getOriginatorID method to determine the destination of an outgoing message. This way, a listener CFC that sends a response back to the originator does not have to explicitly set a destination in the return variable. If the field is empty, (as it is in messages sent by the CFML SendGatewayMessage function) the gateway tries to get the destination from the CFevent 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; 
}