Real-Time communication between PHP and Flex application

前端 未结 3 1753
自闭症患者
自闭症患者 2021-01-27 15:42

I have a Flex/AIR application communicating with a PHP server application. Recently my client requested real-time-like connectivity between the applications to replace what we c

相关标签:
3条回答
  • 2021-01-27 15:57

    Actually you can push data from the server to the client, when using Flash sockets (which means bypassing the http protocol). If you cannot use sockets you can use things like polling, long polling or http streaming. However it will take a while to do everything by hand, so I suggest looking at a product which already has this features. WebOrb for PHP is one of them, and from what I know is free.

    0 讨论(0)
  • 2021-01-27 16:11

    I'm no flex developer so I'm not going to provide you some code to help with this situation but I can provide you some ideas of how you would go about aproaching this.

    Instead of looking for PHP to push to Flex I would setup your Flex code to constantly probe the PHP for new happenings. You can probe every second if you can be sure that the server will respond quick enough. Alternatively something that probes ever 5 seconds would still be real time.

    If PHP is sending DATA back to your flex app then I would make sure it sends IDs with the data so that you can use that ID in your flex app to know what was the last data returned. Each time you probe PHP send the last ID you recieved that way telling PHP only to send new DATA after that ID. Many a time you will probe and there wont be anything comming back but its better than recieving the same data over and over again and wasting bandwidth and proccesses figuring out if the data is already shown on screen.

    0 讨论(0)
  • 2021-01-27 16:16

    You cannot push data from the server to the client. That's the nature of the web :(

    What you have to do is continuously poll the server from the client and check if something has changed.

    If something has changed then you can take the necessary actions. This is how google / facebook and everyone else does this. To the user it looks like the server pushed the data but internally the client keeps polling the server.

    0 讨论(0)
提交回复
热议问题