You are developing an ASP.NET MVC application that provides instant messaging capabilities to customers.
You have the following requirements:
Messages must be able to be sent and received simultaneously.
Latency and unnecessary header data must be eliminated.
The application must comply with HTML5 standards.You need to design the application to meet the requirements.
What should you do?
A.
Configure polling from the browser.
B.
Implement long-running HTTP requests.
C.
Implement WebSockets protocol on the client and the server.
D.
Instantiate a MessageChannel object on the client.
wrong
answer is C
sorry… D
is correct
Answer should be C.
https://stackoverflow.com/questions/29620567/difference-between-messagechannel-and-websockets
I agree
MessageChannel allows to page communicate directly
answer is correct: D
Correct answer is C.
The question is a bit ambiguous that is why we can think D is correct, but MessageChannel serves a different purpose.
– MessageChannel: The Channel Messaging API allows two separate running scripts in different browsing contexts attached to the same document (e.g., two IFrames, or the main document and an IFrame, or two documents via SharedWorker) to communicate directly.
– WebSockets is an advanced technology that makes it possible to open an 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
The Question states that the ASP.Net app provides IM communications, so the server interaction is required. ergo we need to use WebSockets.
sources:
– WebSockets: https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API
– MessageChannel: https://developer.mozilla.org/en-US/docs/Web/API/Channel_Messaging_API/Using_channel_messaging
https://stackoverflow.com/questions/29620567/difference-between-messagechannel-and-websockets