wip
This commit is contained in:
@@ -5,27 +5,34 @@
|
||||
<title>WebSocket Test</title>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
let connect = function() {
|
||||
let host = window.location.host;
|
||||
|
||||
if (host.indexOf(":") != -1) {
|
||||
host = host.substr(0,host.indexOf(":"));
|
||||
}
|
||||
|
||||
|
||||
// Replace 'ws://localhost/ws' with your WebSocket server address
|
||||
var ws = new WebSocket('ws://'+host+':1025/ws');
|
||||
|
||||
|
||||
ws.onopen = function() {
|
||||
console.log('WebSocket connection established');
|
||||
};
|
||||
|
||||
|
||||
ws.onmessage = function(event) {
|
||||
console.log('Message received: ' + event.data);
|
||||
};
|
||||
|
||||
|
||||
ws.onclose = function() {
|
||||
console.log('WebSocket connection closed');
|
||||
setTimeout(function() {
|
||||
connect();
|
||||
}, 5000);
|
||||
};
|
||||
};
|
||||
|
||||
$(document).ready(function() {
|
||||
connect();
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
|
||||
Reference in New Issue
Block a user