ColdFusion 9.0 Resources |
Sending messagesYour ColdFusion application sends a message to a Flex application by calling the ColdFusion SendGatewayMessage function. In messages sent from CFML, the following structure members are translated to the Flex message:
ExampleThe following example creates a structure for each event type. It then creates a structure that contains the message. The message structure contains an array of event structures to send to Flex. The destination is the destination ID specified in the flex-services.xml file for the instance of the Data Management event gateway to send the message to. The body is the body of the message. The sendGatewyMessage CFML function sends the message to the instance of the gateway. <cfscript> // Create event createEvent = StructNew(); createEvent.action = "create"; createEvent.item = newContact; // Create update notification updateEvent = StructNew(); updateEvent.action="update"; updateEvent.previousversion = oldContact; updateEvent.newversion = updatedContact; // Create delete notification identity = StructNew(); identity["contactId"] = newId; deleteEvent = StructNew(); deleteEvent.action = "deleteID"; deleteEvent.identity = identity; // Send a batch notification all = StructNew(); all.destination="cfcontact"; all.action="batch"; all.changes = ArrayNew(1); all.changes[1] = createEvent; all.changes[2] = updateEvent; all.changes[3] = deleteEvent; r = sendGatewayMessage("LCDS", all); </cfscript> |