Html程序  |  20行  |  407 B

<!doctype html>
<html>
<head>
<title>Connect to a WebSocket server</title>
<script type="text/javascript">
var protocol = location.protocol.replace('http', 'ws');
var url = protocol + '//' + location.host + '/count-connection';
var ws = new WebSocket(url);

ws.onopen = function() {
    document.title = 'CONNECTED';
};

ws.onclose = function() {
    document.title = 'CLOSED';
};
</script>
</head>
</html>