Solved

Real-Time communication between PHP and Flex application

Posted on 2010-11-19
4
475 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

679 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