server-sent-events

HTML5 Server-Sent Events prototyping - ambiguous error and repeated polling?

*爱你&永不变心* 提交于 2019-11-26 16:54:42
问题 I'm trying to get to grips with Server-Side Events as they fit my requirements perfectly and seem like they should be simple to implement, however I can't get past a vague error and what looks like the connection repeatedly being closed and re-opened. Everything I have tried is based on this and other tutorials. The PHP is a single script: <?php header('Content-Type: text/event-stream'); header('Cache-Control: no-cache'); function sendMsg($id, $msg) { echo "id: $id" . PHP_EOL; echo "data:

WebSockets vs. Server-Sent events/EventSource

社会主义新天地 提交于 2019-11-26 01:19:23
问题 Both WebSockets and Server-Sent Events are capable of pushing data to browsers. To me they seem to be competing technologies. What is the difference between them? When would you choose one over the other? 回答1: Websockets and SSE (Server Sent Events) are both capable of pushing data to browsers, however they are not competing technologies. Websockets connections can both send data to the browser and receive data from the browser. A good example of an application that could use websockets is a

What are Long-Polling, Websockets, Server-Sent Events (SSE) and Comet?

江枫思渺然 提交于 2019-11-25 21:44:54
问题 I have tried reading some articles, but I am not very clear on the concepts yet. Would someone like to take a shot at explaining to me what these technologies are: Long Polling Server-Sent Events Websockets Comet One thing that I came across every time was, the server keeps a connection open and pushes data to the client. How is the connection kept open, and how does the client get the pushed data? (How does the client use the data, maybe some code might help?) Now, which one of them should I