websockets in faces3.php
This commit is contained in:
parent
44f8d68f50
commit
36be41bafc
1 changed files with 6 additions and 5 deletions
|
@ -415,20 +415,21 @@ echo "</div>"; // .currentHit
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var socket = new WebSocket("ws://<?php echo $_SERVER['SERVER_NAME']; ?>:8181");
|
var socket = new WebSocket("ws://<?php echo $_SERVER['SERVER_NAME']; ?>:8181");
|
||||||
connection.onopen = function(){
|
socket.onopen = function(){
|
||||||
/*Send a small message to the console once the connection is established */
|
/*Send a small message to the console once the connection is established */
|
||||||
console.log('Connection open!');
|
console.log('Connection open!');
|
||||||
};
|
};
|
||||||
connection.onclose = function(){
|
socket.onclose = function(){
|
||||||
console.log('Connection closed');
|
console.log('Connection closed');
|
||||||
connection.connect()
|
location.reload();
|
||||||
|
// socket.connect()
|
||||||
}
|
}
|
||||||
connection.onerror = function(error){
|
socket.onerror = function(error){
|
||||||
// reload page
|
// reload page
|
||||||
console.log('Error detected: ' + error);
|
console.log('Error detected: ' + error);
|
||||||
location.reload();
|
location.reload();
|
||||||
}
|
}
|
||||||
connection.onmessage = function(e){
|
socket.onmessage = function(e){
|
||||||
var message = JSON.parse(e.data);
|
var message = JSON.parse(e.data);
|
||||||
// var server_message = e.data;
|
// var server_message = e.data;
|
||||||
console.log(message);
|
console.log(message);
|
||||||
|
|
Loading…
Reference in a new issue