m0serve live demo

Open this page in a second tab and type in either pane, in either tab. Every pane in every tab shows it within the second. The left pane is a held Server-Sent Events stream, the right a WebSocket. Both were approved by an ordinary synchronous Django view answering with two response headers; the server holds the connection from there.

Server-Sent Events

connecting…

new EventSource("/events") · POST /publish

    WebSocket

    connecting…

    new WebSocket("/ws") · ws.send(text)