Page 1 of 1

SSE example

Posted: Tue Aug 11, 2020 5:44 am
by dakosimo
Is it possible to use Server-Sent-Events in Mod-harbour and Mercury ? How to define and use EventSource ?
I did not find any example in mod_harbour_samples.
On Internet there are samples for PHP, but I do not know how to realize it using Mercury. I made this view:

{{ View( 'head.view' ) }}
<body>
<h1>Testing SSE</h1>

<div id="result">

</div>

<script>
if(typeof(EventSource) !== "undefined") {
var source = new EventSource("servtime.prg");
source.onmessage = function(event) {
document.getElementById("result").innerHTML += event.data + "<br>";
};
} else {
document.getElementById("result").innerHTML = "Sorry, your browser does not support server-sent events...";
}
</script>

</body>
</html>

In servtime.prg I have:

FUNCTION Servtime()

LOCAL stime = TIME()
AP_RPuts( stime )

RETURN NIL

Servtime.prg I put in document root, in place where index.prg exists also.

On display I only get Testing SSE as header text, but no time.

Thank you and Best regards.

Dako.

Re: SSE example

Posted: Tue Aug 11, 2020 10:12 am
by Antonio Linares
Dako,

It is not implemented yet and it may work on the mod_harbour fastCGI version only

We are studying the way to implement it

Re: SSE example

Posted: Tue Aug 11, 2020 10:25 am
by dakosimo
I will wait. It is not urgent.
Thank you.
Best regards.

Dako.