ColdFusion 9.0 Resources |
outgoingMessageSee alsoResponding to a ColdFusion function or listener CFC in the Developing ColdFusion Applications Parameters
UsageThis 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. ExampleThe 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; } |