Websocket only sends a message if onopen was invoked and no where else. The server just sends back the message with Hello added.
Client side:
<!DOCTYPE html>
<html>
<body>
<button onclick="transmit()">send</button>
<h3 id="text"></h3>
</body>
<script>
const url = "ws://localhost:8765"
const ws = new WebSocket(url)
var i = 0;
ws.onopen = function (event) {
ws.send('On');
}
ws.onmessage = function (event){
ws.send("This will cause a feedback loop but idc at this point");
var text = document.getElementById("text");
text.innerHTML = evt.data;
}
ws.send("pain");
</script>
</html>
I am probably doing something stupid lol.