inital commit
This commit is contained in:
22
wsgorillatest/websockets.html
Normal file
22
wsgorillatest/websockets.html
Normal file
@@ -0,0 +1,22 @@
|
||||
<!-- websockets.html -->
|
||||
<input id="input" type="text" />
|
||||
<button onclick="send()">Send</button>
|
||||
<pre id="output"></pre>
|
||||
<script>
|
||||
var input = document.getElementById("input");
|
||||
var output = document.getElementById("output");
|
||||
var socket = new WebSocket("ws://localhost:8080/echo");
|
||||
|
||||
socket.onopen = function () {
|
||||
output.innerHTML += "Status: Connected\n";
|
||||
};
|
||||
|
||||
socket.onmessage = function (e) {
|
||||
output.innerHTML += "Server: " + e.data + "\n";
|
||||
};
|
||||
|
||||
function send() {
|
||||
socket.send(input.value);
|
||||
input.value = "";
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user