mardi 18 juillet 2017

Looking for placeholder or test SSE website

I am an junior developer and have been learning how to capture data using HTML GET requests and Java Servlets + JSP pages for display. I found JSON Placeholder to be extremely useful for learning how to capture sets of data. Although now I have to capture continuously updated data over SSE. I am completely new to the idea of SSE and want to learn. In order to learn I would like if there was dummy website that was sending out data that I could subscribe to. The only alternative to this would be to learn how to setup my own but I am not too familiar with PHP, Node.js or ASP. So, are there any resources that already do this or will I have to set up my own?

Here is the code that I have been messing with to display the Events:

<!DOCTYPE html>
<html>
<body>

<h1>Getting server updates</h1>
<div id="result"></div>

<script>
    if(typeof(EventSource) !== "undefined") {
        var source = new EventSource("This is where I need the placeholder");
        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>

Aucun commentaire:

Enregistrer un commentaire