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.