Skip to content

Instantly share code, notes, and snippets.

@imageaid
Created December 14, 2010 16:02
Show Gist options
  • Save imageaid/740622 to your computer and use it in GitHub Desktop.
Save imageaid/740622 to your computer and use it in GitHub Desktop.
<cfscript>
if(lcase(trim(cgi.request_method)) == 'post'){
sendChatRequestMessage();
}
</cfscript>
<cfoutput>
<html>
<head>
<title>Client-Specific Announcements</title>
</head>
<body>
<div>
Press 'Go' to send an announcement to a specific Flex client.
</div>
<form action="#cgi.script_name#" method="post">
<input type="submit" value="Go" />
</form>
</body>
</html>
</cfoutput>
<cffunction name="sendChatRequestMessage" hint="I send a message to another member requesting a chat" displayname="sendChatRequestMessage" access="public" returntype="boolean">
<cfscript>
var message_sent = false;
var msg = createObject("java","com.pojo.messages.MessageBody");//POJO
var messageService = createObject("java","com.gateways.adapters.JMSPublisher");
var message_body = "Craig would like to chat with you!";
// set up generic obejct/struct for message details
// POJO for Message Object -- in my real-world scenario, the props in this object are used in the Flex client.
// For this demo, they're just dummy props but you could put a breakpoint in Flex/Flash Builder and see the full details for the object
msg = createObject("java","com.kronum.pojo.messages.MessageBody");
msg.setMessage(message_body);
msg.setMessageType("Friend Chat Notifier");
msg.setMessageUserName('craig');
msg.setMessageMemberID('F03D-CF2E');
// fire up the messaging service and send the message.
// in a real application, we would make "friendchatroom.1" dynamic.
try{
messageService.publishMessage(msg,"kronumMessages","friendchatroom.1");
message_sent = true;
}
catch(Any e){
//empty for demonstration purposes
}
</cfscript>
<cfreturn message_sent />
</cffunction>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment