enet/test/main-client-websocket.html

40 lines
983 B
HTML

<!DOCTYPE HTML>
<html>
<head>
<script type="text/javascript">
function WebSocketTest() {
if ("WebSocket" in window) {
} else {
// The browser doesn't support WebSocket
alert("WebSocket NOT supported by your Browser!");
return;
}
alert("WebSocket is supported by your Browser!");
// Let us open a web socket
//var ws = new WebSocket("ws://localhost:1983");
var ws = new WebSocket("ws://localhost:12345/plop.txt");
ws.onopen = function() {
// Web Socket is connected, send data using send()
ws.send("Message to send");
alert("Message is sent...");
};
ws.onmessage = function (evt) {
var received_msg = evt.data;
alert("Message is received...");
};
ws.onclose = function() {
// websocket is closed.
alert("Connection is closed...");
};
}
</script>
</head>
<body>
<div id="sse">
<a href="javascript:WebSocketTest()">Run WebSocket</a>
</div>
</body>
</html>