I can't figure out what is difference between MessageChannel and WebSockets?
I need following requirements:
Are both fullfil this requirements? Which is better?
The MessageBroker WebSocket Subprotocol (MBWS) is a WebSocket Subprotocol used by messaging clients to send messages to, and receive messages from an internet message broker (herein called a message broker).
The WebSocket API is an advanced technology that makes it possible to open a two-way interactive communication session between the user's browser and a server. With this API, you can send messages to a server and receive event-driven responses without having to poll the server for a reply.
WebSocket URIs have the same basic format as HTTP URIs, but with a different URI scheme: ws://hostname:port/path, e.g. ws://example.com/echo or ws://example.net:8080. The path can be used to distinguish the purpose of the connection; however, some servers ignore it.
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 from the Opera dev portal:
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 can be used to communicate between code loaded in the browser and the server. So it serves a completely different purpose. Since you're mentioning the requirement of low latency and "full-duplex" I assume you mean client-server communication, and so you're looking for a web sockets.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With