Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 490
  • Last Modified:

Real-Time communication between PHP and Flex application

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
DReade83
Asked:
DReade83
  • 2
2 Solutions
 
PankajRaiCommented:
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
 
edchipmanCommented:
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
 
DReade83Author Commented:
Is that classed as "long polling"? Should I be using persistent connections with Apache or is that not recommended?
0
 
edchipmanCommented:
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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now