HTML and CSS Reference
In-Depth Information
have complete access to your entire DOM—it's not possible to give them only partial ac-
cess when they're loaded this way. Cross-document messaging works cross-domain, en-
abling messages to be sent between separate applications without exposing each applica-
tion's DOM.
Enabling one-way communications from server to client with server-sent events
Cross-document messaging is a great way to communicate between two clients—but what
if you want to allow your web server to send messages that can be read by the browser?
Server-sent events are designed to do that. Using the EventSource interface, your ap-
plication can subscribe to a server-side event stream, which will only receive messages
when the server sends an update. This is a considerable improvement over approaches like
AJAX long polling, which can be cumbersome to implement. This works well for a chat
application, where you can post new chat messages using AJAX and receive any chat mes-
sages from other users over the event stream. Figure 1.11 is a screenshot of such an applic-
ation, which you'll build later on.
Figure 1.11. A chat application implemented using server-sent events
 
Search WWH ::




Custom Search