Now ws-client only targets _onmessage when same URL+URI
This commit is contained in:
parent
7e2714222d
commit
360c2f7133
|
@ -132,6 +132,10 @@ class WSClient{
|
|||
return;
|
||||
}
|
||||
|
||||
/* (3) If not for this channel -> exit */
|
||||
if( msg_event.target.url != this.server_url+'/'+this.channel_uri )
|
||||
return;
|
||||
|
||||
/* (3) Try to JSON parse */
|
||||
var parsedMsg = null;
|
||||
try{
|
||||
|
|
17
view/main.js
17
view/main.js
|
@ -38,10 +38,11 @@ new Vue({
|
|||
/* (1) Connection channel */
|
||||
window.wsc_connect = window.wsc.channel('connect').listen(function(msg, err){
|
||||
|
||||
console.log('connect received', msg, err);
|
||||
// {1} Manage error //
|
||||
if( msg == null && err != null ){
|
||||
window.gstore.data.info.message = 'Erreur de connexion WebSocket@connect ('+err+')';
|
||||
window.gstore.data.info.type = 'warning';
|
||||
window.gstore.data.info.type = 'error';
|
||||
window.gstore.data.info.active = true;
|
||||
setTimeout(function(){ window.gstore.data.info.active=false; }, 5000);
|
||||
/*TEMP*/return;
|
||||
|
@ -49,10 +50,9 @@ window.wsc_connect = window.wsc.channel('connect').listen(function(msg, err){
|
|||
}
|
||||
|
||||
// {2} Manage wsclient error //
|
||||
if( msg.connected == null || msg.error == null || msg.error !== 0 ){
|
||||
if( msg.connected == null || typeof msg.error != 'boolean' || msg.error !== false ){
|
||||
console.warn('websocket error: '+msg.error);
|
||||
if( msg.error == null ) window.gstore.data.info.message = 'Erreur de connexion WebSocket@connect (Unknown Error)';
|
||||
else window.gstore.data.info.message = 'Erreur de connexion WebSocket@connect ('+msg.error+')';
|
||||
window.gstore.data.info.message = 'Erreur de connexion WebSocket@connect';
|
||||
window.gstore.data.info.type = 'warning';
|
||||
window.gstore.data.info.active = true;
|
||||
setTimeout(function(){ window.gstore.data.info.active=false; }, 5000);
|
||||
|
@ -69,10 +69,12 @@ window.wsc_connect = window.wsc.channel('connect').listen(function(msg, err){
|
|||
/* (2) Message channel */
|
||||
window.wsc_chat = window.wsc.channel('chat').listen(function(msg, err){
|
||||
|
||||
console.log('chat received', msg, err);
|
||||
|
||||
// {1} Manage error //
|
||||
if( msg == null && err != null ){
|
||||
window.gstore.data.info.message = 'Erreur de connexion WebSocket@connect ('+err+')';
|
||||
window.gstore.data.info.type = 'warning';
|
||||
window.gstore.data.info.type = 'error';
|
||||
window.gstore.data.info.active = true;
|
||||
setTimeout(function(){ window.gstore.data.info.active=false; }, 5000);
|
||||
/*TEMP*/return;
|
||||
|
@ -80,10 +82,9 @@ window.wsc_chat = window.wsc.channel('chat').listen(function(msg, err){
|
|||
}
|
||||
|
||||
// {2} Manage wsclient error //
|
||||
if( msg.msg == null || msg.error == null || msg.error !== 0 ){
|
||||
if( msg.msg == null || typeof msg.error != 'boolean' || msg.error !== false ){
|
||||
console.warn('websocket error: '+msg.error);
|
||||
if( msg.error == null ) window.gstore.data.info.message = 'Erreur de connexion WebSocket@connect (Unknown Error)';
|
||||
else window.gstore.data.info.message = 'Erreur de connexion WebSocket@connect ('+msg.error+')';
|
||||
window.gstore.data.info.message = 'Erreur de connexion WebSocket@connect';
|
||||
window.gstore.data.info.type = 'warning';
|
||||
window.gstore.data.info.active = true;
|
||||
setTimeout(function(){ window.gstore.data.info.active=false; }, 5000);
|
||||
|
|
Loading…
Reference in New Issue