mirror of
https://github.com/labstack/echo.git
synced 2024-12-20 19:52:47 +02:00
093e5c9ed6
Signed-off-by: Vishal Rana <vr@labstack.com>
40 lines
656 B
HTML
40 lines
656 B
HTML
<!doctype html>
|
|
<html lang="en">
|
|
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>WebSocket</title>
|
|
</head>
|
|
|
|
<body>
|
|
<p id="output"></p>
|
|
|
|
<script>
|
|
var loc = window.location;
|
|
var uri = 'ws:';
|
|
|
|
if (loc.protocol === 'https:') {
|
|
uri = 'wss:';
|
|
}
|
|
uri += '//' + loc.host;
|
|
uri += loc.pathname + 'ws';
|
|
|
|
ws = new WebSocket(uri)
|
|
|
|
ws.onopen = function() {
|
|
console.log('Connected')
|
|
}
|
|
|
|
ws.onmessage = function(evt) {
|
|
var out = document.getElementById('output');
|
|
out.innerHTML += evt.data + '<br>';
|
|
}
|
|
|
|
setInterval(function() {
|
|
ws.send('Hello, Server!');
|
|
}, 1000);
|
|
</script>
|
|
</body>
|
|
|
|
</html>
|