Server Sent Events - Prevent Closing of Socket
Posted: Mon Jun 29, 2020 4:52 pm
I am messing about with server sent events in livecode server. I have made a start by translating the php example found here https://www.html5rocks.com/en/tutorials ... ce/basics/
Here is my very basic code to start with...
It resides in a file called "sse.lc" on the root of my server
I created an html called ssetest.html with the script as per example (I have replaced "events.php" with "sse.lc")
yippo.livecodehosting.com/ssetest.html
In the browser console the sse.lc page keeps transmitting the string "Server Time XXXXX Server Date: XXXXX" every 3 seconds.
I believe lc server is closing the connection every time i "put" data even though I have specified "Connection: keep-alive" in the header response.
Is there any way way to keep the connection alive but still transmit data back to the client?
I've had livecode hosting for years and it's about time I started to have a play with it.
Here is my very basic code to start with...
Code: Select all
<?lc
put header "Content-Type: text/event-stream"
put header "Cache-Control: no-cache"
put header "Connection: keep-alive"
put "data: Server Time:" && the time && "Server Date:" && the date & crlf & crlf
?>
I created an html called ssetest.html with the script as per example (I have replaced "events.php" with "sse.lc")
yippo.livecodehosting.com/ssetest.html
In the browser console the sse.lc page keeps transmitting the string "Server Time XXXXX Server Date: XXXXX" every 3 seconds.
I believe lc server is closing the connection every time i "put" data even though I have specified "Connection: keep-alive" in the header response.
Is there any way way to keep the connection alive but still transmit data back to the client?
I've had livecode hosting for years and it's about time I started to have a play with it.