essai reco websocket
This commit is contained in:
parent
2e34d65cbf
commit
b29ce57c6e
@ -120,7 +120,7 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block localjavascript %}
|
||||
var webSocket;
|
||||
var webSocket;
|
||||
|
||||
$(document).ready(function(){
|
||||
if (CKEDITOR.instances["chat_message"]) CKEDITOR.instances["chat_message"].destroy();
|
||||
@ -147,14 +147,25 @@
|
||||
},500);
|
||||
|
||||
$(".switch").bootstrapSwitch();
|
||||
var dateoptions = {weekday: "long", year: "numeric", month: "long", day: "numeric", hour: "2-digit", minute: "2-digit" };
|
||||
$("#mymodal-sendmail").removeAttr("tabindex");
|
||||
|
||||
websocket();
|
||||
|
||||
});
|
||||
|
||||
function websocket()
|
||||
{
|
||||
{% if websocket_activate and app.user %}
|
||||
var _WS_URI = "wss://{{ gos_web_socket_server_host }}:{{ gos_web_socket_server_port }}";
|
||||
webSocket = WS.connect(_WS_URI);
|
||||
var timer;
|
||||
|
||||
console.log("INI WS");
|
||||
webSocket = WS.connect(_WS_URI);
|
||||
console.log("END INI WS");
|
||||
|
||||
var dateoptions = {weekday: "long", year: "numeric", month: "long", day: "numeric", hour: "2-digit", minute: "2-digit" };
|
||||
var timer;
|
||||
var session;
|
||||
|
||||
webSocket.on("socket/connect", function (session) {
|
||||
// Reinit du tps de tentative de reco
|
||||
$('#modalinfo').modal('hide');
|
||||
@ -260,39 +271,50 @@
|
||||
|
||||
webSocket.on("socket/disconnect", function(error){
|
||||
laberror="Disconnected for " + error.reason + " with code " + error.code;
|
||||
console.log("=== DISCONNECT ===");
|
||||
console.log(laberror);
|
||||
|
||||
$('#modalinfo').modal('show');
|
||||
|
||||
if(error.code==2) {
|
||||
$('#modalinfo').modal('show');
|
||||
$('#modalinfotext').html("<center>Impossible de se connecter au serveur.<br>Vous avez dépassé le nombre de reconnexion maximum<br><br>Veuillez retentez d'ici quelques secondes<br><br><code>"+laberror+"</code><br><br><div id='modalinfotimer'></div><br><a class='btn btn-primary' onclick='location.reload(true);'>Forcer la tentative de reconnexion</a></center>");
|
||||
|
||||
clearInterval(timer);
|
||||
var nbtentative=10;
|
||||
timer=setInterval(function(){ $('#modalinfotimer').html((nbtentative--)+"s") }, 1000);
|
||||
|
||||
setTimeout(function(){ location.reload(true); }, 10000);
|
||||
setTimeout(function(){ websocket(); }, 10000);
|
||||
//setTimeout(function(){ location.reload(true); }, 10000);
|
||||
}
|
||||
|
||||
if(error.code==3) {
|
||||
$('#modalinfo').modal('show');
|
||||
$('#modalinfotext').html("<center>Impossible de se connecter au serveur.<br>Veuillez retentez d'ici quelques secondes<br><br><code>"+laberror+"</code><br><br><div id='modalinfotimer'></div><br><a class='btn btn-primary' onclick='location.reload(true);'>Forcer la tentative de reconnexion</a></center>");
|
||||
|
||||
clearInterval(timer);
|
||||
var nbtentative=10;
|
||||
timer=setInterval(function(){ $('#modalinfotimer').html((nbtentative--)+"s") }, 1000);
|
||||
|
||||
setTimeout(function(){ location.reload(true); }, 10000);
|
||||
setTimeout(function(){ websocket(); }, 10000);
|
||||
// setTimeout(function(){ location.reload(true); }, 10000);
|
||||
}
|
||||
|
||||
if(error.code==6 || error.code==5) {
|
||||
|
||||
$('#modalinfotext').html("<center>Impossible de se connecter au serveur.<br>Vous allez être reconnecté d'ici quelques secondes<br><br><code>"+laberror+"</code><br><br><div id='modalinfotimer'></div><br><a class='btn btn-primary' onclick='location.reload(true);'>Forcer la tentative de reconnexion</a></center>");
|
||||
|
||||
clearInterval(timer);
|
||||
var nbtentative=5;
|
||||
//session.unsubscribe("websocket/channel/{{groupid}}");
|
||||
websocket();
|
||||
/*
|
||||
timer=setInterval(function(){ $('#modalinfotimer').html((nbtentative--)+"s") }, 1000);
|
||||
setTimeout(function(){ websocket(); }, 10000);
|
||||
*/
|
||||
}
|
||||
});
|
||||
|
||||
{% endif %}
|
||||
});
|
||||
}
|
||||
|
||||
{% endblock %}
|
Loading…
Reference in New Issue
Block a user