. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
| Server IP : 52.223.31.75 / Your IP : 172.31.32.98 [ Web Server : Apache/2.4.66 () OpenSSL/1.0.2k-fips PHP/7.4.33 System : Linux ip-172-31-14-81.eu-central-1.compute.internal 4.14.281-212.502.amzn2.x86_64 #1 SMP Thu May 26 09:52:17 UTC 2022 x86_64 User : apache ( 48) PHP Version : 7.4.33 Disable Function : NONE Domains : 4 Domains MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /var/www/ripara.co/admin/websoket/ |
Upload File : |
<html>
<body>
<script type="text/javascript">
/*
stati web socket
const unsigned short CONNECTING = 0;
const unsigned short OPEN = 1;
const unsigned short CLOSING = 2;
const unsigned short CLOSED = 3;
*/
//protocollo wss:// se usiamo SSL
function initWS(){
if (!'WebSocket' in window){
alert('<span style="color: red;">ERROR: Update your browser to one that supports websockets. A list can be found <a href="http://caniuse.com/websockets">here</a></span>');
return null;
}
var socket = new WebSocket("ws://localhost:8080");
socket.onopen = function (){
// Funzione eseguita all'apertura della connessione
document.write("connessione stabilita");
}
socket.onclose = function(){
// Funzione eseguita alla chiusura della connessione
document.write("connessione chiusa");
}
socket.onerror = function(e){
// Funzione eseguita in caso di errore
document.write("Errore:");
dump(e);
}
socket.onmessage = function(data) {
// Funzione eseguita alla ricezione di un messaggio
// Il parametro 'data' rappresenta il contenuto del messaggio
alert(data);
}
return socket;
}
wsocket = initWS();
//invio messaggio al server
//socket.send("messaggio d'esempio");
function dump(obj) {
var out = '';
for (var i in obj) {
out += i + ": " + obj[i] + "\n";
}
//alert(out);
// or, if you wanted to avoid alerts...
var pre = document.createElement('pre');
pre.innerHTML = out;
document.body.appendChild(pre)
}
</script>
</body>
</html>