Solved

Real-Time communication between PHP and Flex application

Posted on 2010-11-19
4
478 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

752 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