Realtime update and Push Data in AS3

2019-02-15 08:53发布

i want to make a real-time update for my flash application. Instead on making it refresh each 30secs, i would prefer the push technology. What is the best way to push data in Actionscript 3 ?

1条回答
趁早两清
2楼-- · 2019-02-15 09:39

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.

查看更多
登录 后发表回答