HTML and CSS Reference
In-Depth Information
Like the forever frame, you gain a low overhead of passing data from the server to the cli-
ent. Once the connection is open, the only data that needs to be transferred is that which is
pertinent to the application. No headers need to be sent with each update.
Step 8: Connect to an SSE stream in the browser
To retrieve chat messages, you'll connect your index.php page to the event stream using
an EventSource object. The next listing shows the relevant JavaScript. You should add
it to the chat.js you created in step 5. In this listing the EventSource is established and
event listeners are added. The annotations explain the key points.
Search WWH ::




Custom Search