Solved

Real-Time communication between PHP and Flex application

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Parts and Products table schema in mysql 6 44
Append letter to end of string 4 36
what is best version of php to use 6 46
updating table data with inner join 9 24
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
The viewer will learn how to count occurrences of each item in an array.
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.

920 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

12 Experts available now in Live!

Get 1:1 Help Now