Re: Server-Sent Events
- Posted by jmduro May 09, 2017
- 3433 views
CraigWelch said...
That’s it. It works. I’m happy to answer any questions or provide any help.
I'm probably missing something cause Firefox allows me only one possibility: to save the source file. It does not execute as with other source code on the same server.
Here is my code:
include std/os.e include std/io.e --******************************************** --* function test_progress() * --******************************************** function test_progress() puts(1,"Cache-Control: no-cache\r\n") puts(1,"Content-Type: text/event-stream\r\n") puts(1,"\r\n") for i = 1 to 100 do sleep(0.1) puts(1, sprintf("data: %d \n\n", i)) -- must have the two newlines flush(1) end for puts(1, "Status: 415 OK") return {"Finished test"} end function test_progress()
Jean-Marc