Skip to main content
Participant
January 17, 2009
Question

Event Gateway Listener interacts with Javascript

  • January 17, 2009
  • 4 replies
  • 456 views
I've tried searching through various solution to try and figure out which direction to take this but I can't find anything yet.

I have an active IM Event Gateway Listener set up on CF 8 server. Its currently working just fine with GTalk. I am trying to figure out how to fire a javascript function on the clients browser when an IM Event Gateway Listener is fired.

For example let's take the onIncomingMessage listener:

<cffunction name="onIncomingMessage">
<cfargument name="CFEvent" type="struct" required="yes">
</cffunction>


Once that is fired and a message has been received how can I have that immediately execute a javascript function waiting to be executed once that listener has been triggered?

I've researched various solutions included DWR, Comet, and "Reverse Ajax" but I'm not sure that's where I want to go.

Is there a way to use the cfajaxproxy call to have it work with a Gateway listener?

Best Regards,

Darren
This topic has been closed for replies.

4 replies

Inspiring
January 27, 2009
darrenlabrum wrote:
>
> Ian, based on what your are saying I should probably look at using something
> like BlazeDS from Adobe to do the "push" functionality. It looks like BlazeDS
> has an ajax javascript client library that can interact with an embedded Flash
> object that receives the data pushed from the server.
>
> http://opensource.adobe.com/wiki/display/blazeds/BlazeDS/

Yes, I believe that is the latest name for what was once called Flex
Data Services. The nice thing is that if you have ColdFusion 8 you
already have a single CPU (and free) version of this service. It is one
of the add on install options when installing ColdFusion. (Similar to
the Verity service for searching).


Participant
January 27, 2009
Thank you for those replies. I appreciate that dynamic Javascript Example from ColdfusionPluginsCom. I will be implementing that type of functionality with that guidance. Thank you again.

Ian, based on what your are saying I should probably look at using something like BlazeDS from Adobe to do the "push" functionality. It looks like BlazeDS has an ajax javascript client library that can interact with an embedded Flash object that receives the data pushed from the server.

http://opensource.adobe.com/wiki/display/blazeds/BlazeDS/

Inspiring
January 26, 2009
Just to try and put some proper terms on your goals here.

What you are trying to do is to PUSH data to the client when an event
occurs on a server. Normal HTTP protocol requests do *not* allow for
pushing of data. It can only pull data from the server and the client
must initiate the request. Even with Ajax.

I have read about some cutting edge techniques that allow for the
fudging of this line between client pulls and server pushes, but my
impression was that they where a bit hokey, not completely reliable and
very specific on which browsers they would actually work with.

The normal way to get server pushing is to have the user interact using
a different client then a http web browser that can maintain a
connection with the server. So that the client can receive data pushed
from the server.

The Adobe preferred client is the Flash Player, and they have provide
the Flex language to make it easier for developers to build integrated
server-client applications like this that utilizes it. There are simple
Flex|Flash|ColdFusion|Air tutorials out there that show this exact user
case. The server pushing new data to the client on some event.

HTH
Ian
Participant
January 26, 2009
Darren,

Correct me if I am wrong but the whole point of AJAX is the browser helps out a little bit and looks for new dynamic javascript code.

For example:
http://www.theautotimes.com/json.cfc?method=helloJSON&format=json&jsoncallback=? returns this mess

The new dynamic javascript code
hello2({"cobblers":[{"filling":"peachremote","timeToBake":30},{"filling":"cherry remote", "timeToBake":35},{"filling":"blueberry remote", "timeToBake":30}]})

The hardwired function
<script type="text/javascript">
function hello2 (data){
alert("JSON Data: " + data.cobblers[0].filling);
}
</script>

So basically I am sending hello2(args);

So send back a function and see if that works and have a function hanging out.