diff --git a/src/ninegate-1.0/src/Cadoles/WebsocketBundle/Resources/views/Chat/client.html.twig b/src/ninegate-1.0/src/Cadoles/WebsocketBundle/Resources/views/Chat/client.html.twig index 3208b15d..d4135296 100644 --- a/src/ninegate-1.0/src/Cadoles/WebsocketBundle/Resources/views/Chat/client.html.twig +++ b/src/ninegate-1.0/src/Cadoles/WebsocketBundle/Resources/views/Chat/client.html.twig @@ -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("
Impossible de se connecter au serveur.
Vous avez dépassé le nombre de reconnexion maximum

Veuillez retentez d'ici quelques secondes

"+laberror+"


Forcer la tentative de reconnexion
"); 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("
Impossible de se connecter au serveur.
Veuillez retentez d'ici quelques secondes

"+laberror+"


Forcer la tentative de reconnexion
"); 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("
Impossible de se connecter au serveur.
Vous allez être reconnecté d'ici quelques secondes

"+laberror+"


Forcer la tentative de reconnexion
"); 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 %} \ No newline at end of file