Files
Testing/testsocket.php
sean 0e8a8b3028
Some checks are pending
deploy-testing / deploy (push) Waiting to run
Initial testing snapshot
2026-11-17 16:15:01 -05:00

39 lines
904 B
PHP

<html><head><title>WebSocket</title>
</head>
<body>
<div id="root"></div>
<script>
var host = 'wss://99.192.174.19:8080/new_websocket.php?ahu22h';
// var socket = new WebSocket(host);
let socket = new WebSocket(host);
socket.onopen = function(e) {
alert("[open] Connection established");
alert("Sending to server");
socket.send("My name is John");
};
socket.onmessage = function(event) {
alert(`[message] Data received from server: ${event.data}`);
};
socket.onclose = function(event) {
if (event.wasClean) {
alert(`[close] Connection closed cleanly, code=${event.code} reason=${event.reason}`);
} else {
// e.g. server process killed or network down
// event.code is usually 1006 in this case
alert('[close] Connection died');
}
};
socket.onerror = function(error) {
alert(`[error] ${error.message}`);
};
</script>
</body>
</html>