✏️ 正在编辑: websocket.js
路径:
/srv/systems_dir/yuppiecred/public/scripts/websocket.js
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
$(document).ready(function () { $.ajax({ type: "POST", dataType: "JSON", url: baseUrl + '/auth/websocket-auth/', beforeSend: function() { $("#loadingWebsocket").html(""); $("#loadingWebsocket").html("<p class='info'>Conectando ao websocket...</p>"); $("#loadingWebsocket").show(); }, success: function (response) { if(response.hasOwnProperty('storage')){ prepareStorage(response.storage) } if(response.hasOwnProperty('channels')){ Notifications.checkForPermission(); var channels = JSON.parse(response.channels); openWebsocketConnection(channels, 1); } }, error: function (response) { console.log(response); }, complete: function(){ $("#loadingWebsocket").hide(); } }); }); function openWebsocketConnection(channels, countCall) { countCall++; $("#loadingWebsocket").show(); var conn = new ab.Session('wss://websocket.sistemayuppie.com.br/wss2/', function() { $("#loadingWebsocket").html(""); console.log("Conectado com sucesso ao websocket!"); for(var channel in channels){ var channel_data = channels[channel]; conn.subscribe(channel_data.id, window[channel]); } }.bind(channels), function(result) { // console.log(result); // console.log(this._websocket_connected); if( countCall <= 2 ){ $("#loadingWebsocket").html(""); $("#loadingWebsocket").html("<p class='error'>Falha ao conectar ao websocket. Tentando novamente...</p>"); openWebsocketConnection(channels, countCall); } }, {'skipSubprotocolCheck': true} ); $("#loadingWebsocket").hide(); } function prepareStorage(storageData) { for(var key in storageData){ localStorage.setItem(key, storageData[key]); } } function chamados(topic, data){ var assuntos = localStorage.getItem("assuntos_chamado"); if(assuntos.search(data.cod_assunto) != -1){ notify(data.titulo, data.mensagem, data.url); } } function propostas(topic, data) { var assuntos = localStorage.getItem("assuntos_proposta"); if(assuntos.search(data.cod_assunto) != -1){ notify(data.titulo, data.mensagem, data.url); } } function agenda(topic, data) { var usuario = localStorage.getItem("usuario"); if(usuario = data.destinatario){ playAudio(); notify(data.titulo, data.mensagem, data.url); } } function simulacao(topic, data) { var assuntos = localStorage.getItem("assuntos_simulacao"); console.log(assuntos); if(assuntos.search(data.cod_assunto) != -1){ playAudio(); notify(data.titulo, data.mensagem, data.url); } } function discador(topic, data) { var ramalAtual = localStorage.getItem('discador-ramal'); if(ramalAtual == data.ramal){ console.log('acionado pelo websocket.js'); $("#loadingWebsocket").html(""); $("#loadingWebsocket").show(); $("#loadingWebsocket").html("<p class='info'>Janela acionada pelo discador!</p>"); $("#loadingWebsocket").hide(); $("#content").load(baseUrl + "/callcenter/exibir-cliente/id/" + data.contato_id + "/chamada_id/" + data.chamada_id + "/popup/1", function(response, status, xhr){ try{ var json = JSON.parse(xhr.responseText); if( json ){ $("#content").html(""); alert(json.alert); } }catch(e) { // } }); } consultarBarraOperador(); }
💾 保存文件
← 返回文件管理器