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;
|
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 */
|
/* (3) Try to JSON parse */
|
||||||
var parsedMsg = null;
|
var parsedMsg = null;
|
||||||
try{
|
try{
|
||||||
|
|
17
view/main.js
17
view/main.js
|
@ -38,10 +38,11 @@ new Vue({
|
||||||
/* (1) Connection channel */
|
/* (1) Connection channel */
|
||||||
window.wsc_connect = window.wsc.channel('connect').listen(function(msg, err){
|
window.wsc_connect = window.wsc.channel('connect').listen(function(msg, err){
|
||||||
|
|
||||||
|
console.log('connect received', msg, err);
|
||||||
// {1} Manage error //
|
// {1} Manage error //
|
||||||
if( msg == null && err != null ){
|
if( msg == null && err != null ){
|
||||||
window.gstore.data.info.message = 'Erreur de connexion WebSocket@connect ('+err+')';
|
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;
|
window.gstore.data.info.active = true;
|
||||||
setTimeout(function(){ window.gstore.data.info.active=false; }, 5000);
|
setTimeout(function(){ window.gstore.data.info.active=false; }, 5000);
|
||||||
/*TEMP*/return;
|
/*TEMP*/return;
|
||||||
|
@ -49,10 +50,9 @@ window.wsc_connect = window.wsc.channel('connect').listen(function(msg, err){
|
||||||
}
|
}
|
||||||
|
|
||||||
// {2} Manage wsclient error //
|
// {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);
|
console.warn('websocket error: '+msg.error);
|
||||||
if( msg.error == null ) window.gstore.data.info.message = 'Erreur de connexion WebSocket@connect (Unknown Error)';
|
window.gstore.data.info.message = 'Erreur de connexion WebSocket@connect';
|
||||||
else window.gstore.data.info.message = 'Erreur de connexion WebSocket@connect ('+msg.error+')';
|
|
||||||
window.gstore.data.info.type = 'warning';
|
window.gstore.data.info.type = 'warning';
|
||||||
window.gstore.data.info.active = true;
|
window.gstore.data.info.active = true;
|
||||||
setTimeout(function(){ window.gstore.data.info.active=false; }, 5000);
|
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 */
|
/* (2) Message channel */
|
||||||
window.wsc_chat = window.wsc.channel('chat').listen(function(msg, err){
|
window.wsc_chat = window.wsc.channel('chat').listen(function(msg, err){
|
||||||
|
|
||||||
|
console.log('chat received', msg, err);
|
||||||
|
|
||||||
// {1} Manage error //
|
// {1} Manage error //
|
||||||
if( msg == null && err != null ){
|
if( msg == null && err != null ){
|
||||||
window.gstore.data.info.message = 'Erreur de connexion WebSocket@connect ('+err+')';
|
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;
|
window.gstore.data.info.active = true;
|
||||||
setTimeout(function(){ window.gstore.data.info.active=false; }, 5000);
|
setTimeout(function(){ window.gstore.data.info.active=false; }, 5000);
|
||||||
/*TEMP*/return;
|
/*TEMP*/return;
|
||||||
|
@ -80,10 +82,9 @@ window.wsc_chat = window.wsc.channel('chat').listen(function(msg, err){
|
||||||
}
|
}
|
||||||
|
|
||||||
// {2} Manage wsclient error //
|
// {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);
|
console.warn('websocket error: '+msg.error);
|
||||||
if( msg.error == null ) window.gstore.data.info.message = 'Erreur de connexion WebSocket@connect (Unknown Error)';
|
window.gstore.data.info.message = 'Erreur de connexion WebSocket@connect';
|
||||||
else window.gstore.data.info.message = 'Erreur de connexion WebSocket@connect ('+msg.error+')';
|
|
||||||
window.gstore.data.info.type = 'warning';
|
window.gstore.data.info.type = 'warning';
|
||||||
window.gstore.data.info.active = true;
|
window.gstore.data.info.active = true;
|
||||||
setTimeout(function(){ window.gstore.data.info.active=false; }, 5000);
|
setTimeout(function(){ window.gstore.data.info.active=false; }, 5000);
|
||||||
|
|
Loading…
Reference in New Issue