outgoingMessage

Description

Sends a message from ColdFusion to a message receiver.

Category

Event Gateway Development

Syntax

public String outgoingMessage(coldfusion.eventgateway.CFEvent message)

See also

Responding to a ColdFusion function or listener CFC in the Developing ColdFusion Applications

Parameters

Parameter

Description

message

A coldfusion.eventgateway.CFEvent instance containing the message to be sent.

Returns

A gateway-specific string, such as a message ID or a status indicator.

Usage

This method handles a message sent by ColdFusion and processes it as needed by the gateway type to send a message to the (usually external) message receiver. ColdFusion calls this method when the listener method of a listener CFC returns a message or when a ColdFusion application calls the SendGatewayMessage function. ColdFusion passes the String returned by this method back as the return value of a CFML SendGatewayMessage function.

Example

The following example is the ColdFusion SocketGateway class outgoingMessage method:

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 && message != null)
{
SocketServerThread st =
((SocketServerThread)socketRegistry.get(cfmsg.getOriginatorID()));
if(st != null)
st.writeOutput(message);
else
{
log.error("Cannot send outgoing message. OriginatorID '" +
cfmsg.getOriginatorID() + "' is not a valid socket id.");
retcode="failed";
}
}
else if (data.get("OriginatorID") != null && message != null)
{
SocketServerThread st =
((SocketServerThread)socketRegistry.get(data.get("OriginatorID")));
if(st != null)
st.writeOutput(message);
else
{
log.error("Cannot send outgoing message. OriginatorID '" +
data.get("OriginatorID") + "' is not a valid socket id.");
retcode="failed";
}
}
else
{
log.error("Cannot send outgoing message. OriginatorID/MESSAGE is not
available.");
retcode="failed";
}
return retcode;
}

 

 Adobe

쉽고 빠르게 지원 받기

신규 사용자이신가요?