Realtime update and Push Data in AS3

空扰寡人 提交于 2019-11-30 23:51:19

There are two popular options for implementing real-time updates: sockets and RTMP. There are advantages and disadvantages to each, but the primary deciding factor is usually your server infrastructure.

Sockets

Sockets provide the lowest-level functionality. This means you will need to implement a protocol in code on the client and on the server. However, the biggest advantage of this approach is that the it can be made to work any server-side technology that supports TCP/IP sockets. You can send data in whichever format you like, but the most efficient would be to use ActionScript Message Format (AMF) to transfer the data in binary format.

RTMP

Real-Time Media Protocol is a protocol developed by Adobe and implemented natively by the Flash Player. Using RTMP would require a specific server which can support the protocol. There are proprietary solutions, as well as free ones. The advantage of using RTMP is that much of the protocol is already implemented, and sharing data can be as simple as setting the value of a shared object - with the protocol handling the data transfer behind the scenes. RTMP encodes messages using AMF so bandwidth usage is efficient. The protocol also supports "tunneling" over HTTP, which means it resorts to polling over HTTP when an RTMP connection is not possible.

Here are some server-side solutions for implementing RTMP and/or AMF:

  1. FluorineFX (.Net)
  2. WebORB (.Net, Java, PHP)
  3. Red5 (Java)
  4. Adobe Flash Media Server (Java)

This entry on Wikipedia describes the RTMP protocol and available servers in more detail.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!