Solved

Real-Time communication between PHP and Flex application

Posted on 2010-11-19
4
460 Views
Last Modified: 2012-05-10
My client wants to replace "refresh" buttons in their Flex/PHP application with real-time refreshing, so as data changes it's pushed to the client.

I've come across a few articles that cover this subject but am struggling to find the best approach. Can anyone suggest any possible solutions?

Any help would be appreciated. Thanks in advance.
0
Comment
Question by:DReade83
  • 2
4 Comments
 
LVL 1

Expert Comment

by:PankajRai
ID: 34174680
the best solution as per my understanding is:

1. create a custom object and bind this object with flex component call setData() method to refresh.
2. write a refress() method in FLEX.
3. when  real time refreshing occur- cal this refress() method from PHP (java Script).

How to call this Method from PHP:

Flex Code
function refresh(data:object):void
{
    // TODO: Refresh the flex application
}
ExternalInterface.addCallback("myFunction", refresh);


// Java Script code
<script language="JavaScript">
   flashObject.myFunction(data);
</script>


0
 
LVL 5

Assisted Solution

by:edchipman
edchipman earned 500 total points
ID: 34174896
We'll with php you can't really "push" the data to the flex clients. However you can poll from the client say every 2 minutes, which you could wait for with a Timer instance. Then when the timer fires just re-fetch the data from php like your probably doing when the flex application loads up for the first time.
0
 

Author Comment

by:DReade83
ID: 34274110
Is that classed as "long polling"? Should I be using persistent connections with Apache or is that not recommended?
0
 
LVL 5

Accepted Solution

by:
edchipman earned 500 total points
ID: 34275489
I wouldn't recommend long polling, as your tieing up the sever. My suggestion would be to simply check with the server see if there is new information say using a time stamp then only send the new data back just like as if you were requesting it in the first place. Even AMF (Action Message Format, Adobe's binary way of sending information to and from a server, basically) connections are not persistent, when you make a new call to the server it reconnects to the server does the request, receives the response and disconnects same as say for example a normal HTTP request.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now