MessageChannel 和 WebSockets 之间的区别?
Difference between MessageChannel and WebSockets?
我搞不懂 MessageChannel 和 WebSockets 有什么区别?
我需要满足以下要求:
- 最小化延迟
- full-duplex
- 最小header数据长度
都满足这个要求吗?哪个更好?
HTML5 Web Messaging API can be used to communicate between independend pieces of code loaded in the browser (specification calls them "browsing contexts"). For example, if your page contains an <iframe>
, and you want to securely communicate between it and the outside code, you might use Web Messaging. Consider this explanation 来自 Opera 开发门户:
Channel messaging is particularly useful for communication across
multiple origins. Consider the following scenario. We have a document
at http://socialsite.example containing content from
http://games.example embedded in one iframe, and content from
http://addressbook.example in another.
Now let’s say that we want to
send a message from our address book site to our games site. We could
use the social site as a proxy. That, however, means the address book
gains the same level of trust as the social site. Our social site
either has to trust every request, or filter them for us.
With channel
messaging, however, http://addressbook.example and
http://games.example can communicate directly.
Web Sockets API 可用于在浏览器中加载的代码与服务器之间进行通信。所以它有一个完全不同的目的。既然你提到了低延迟的要求 "full-duplex" 我假设你的意思是客户端-服务器通信,所以你正在寻找一个网络套接字。
我搞不懂 MessageChannel 和 WebSockets 有什么区别?
我需要满足以下要求:
- 最小化延迟
- full-duplex
- 最小header数据长度
都满足这个要求吗?哪个更好?
HTML5 Web Messaging API can be used to communicate between independend pieces of code loaded in the browser (specification calls them "browsing contexts"). For example, if your page contains an <iframe>
, and you want to securely communicate between it and the outside code, you might use Web Messaging. Consider this explanation 来自 Opera 开发门户:
Channel messaging is particularly useful for communication across multiple origins. Consider the following scenario. We have a document at http://socialsite.example containing content from http://games.example embedded in one iframe, and content from http://addressbook.example in another.
Now let’s say that we want to send a message from our address book site to our games site. We could use the social site as a proxy. That, however, means the address book gains the same level of trust as the social site. Our social site either has to trust every request, or filter them for us.
With channel messaging, however, http://addressbook.example and http://games.example can communicate directly.
Web Sockets API 可用于在浏览器中加载的代码与服务器之间进行通信。所以它有一个完全不同的目的。既然你提到了低延迟的要求 "full-duplex" 我假设你的意思是客户端-服务器通信,所以你正在寻找一个网络套接字。