upd: view.websocket (updated 'response.data' instead of 'response.msg' for channels: /event AND /emergency

This commit is contained in:
xdrm-brackets 2017-12-07 19:15:20 +01:00
parent ece78fa1bd
commit ad575c3697
1 changed files with 8 additions and 9 deletions

View File

@ -16,25 +16,24 @@ window.wsc_emergency = wsc.channel('emergency').listen(function(msg, err){
return infobox.show('Erreur de connexion WebSocket@emergency', 'warning', 3000); return infobox.show('Erreur de connexion WebSocket@emergency', 'warning', 3000);
/* (3) If no message -> exit */ /* (3) If no message -> exit */
if( msg.msg == null ) if( msg.data == null )
return; return;
/* (4) Play sound if 1msg received + not already on page */ /* (4) Play sound if 1msg received + not already on page */
// note: 1msg means a new message but not the page load past buffer // note: 1msg means a new message but not the page load past buffer
if( msg.msg.length == 1 && router.app.$route.path != '/emergency' ) if( msg.data.length == 1 && router.app.$route.path != '/emergency' )
( new Audio('https://notificationsounds.com/message-tones/communication-channel-519/download/mp3') ).play(); ( new Audio('https://notificationsounds.com/message-tones/communication-channel-519/download/mp3') ).play();
/* (5) Add messages to stack */ /* (5) Add messages to stack */
gstore.data.notif.emergency.data = gstore.data.notif.emergency.data.concat( msg.msg ); gstore.data.notif.emergency.data = gstore.data.notif.emergency.data.concat( msg.data );
/* (6) Add notification count if not already on page */ /* (6) Add notification count if not already on page */
if( router.app.$route.path != '/emergency' ) if( router.app.$route.path != '/emergency' )
gstore.data.notif.emergency.count += msg.msg.length; gstore.data.notif.emergency.count += msg.data.length;
/* (7) Remove loader */ /* (7) Remove loader */
gstore.data.msg_pending.emergency = false; gstore.data.msg_pending.emergency = false;
}).send({name: _SERVER.session.name}); }).send({name: _SERVER.session.name});
/* (2) Event channel /* (2) Event channel
@ -50,20 +49,20 @@ window.wsc_event = wsc.channel('event').listen(function(msg, err){
return infobox.show('Erreur de connexion WebSocket@event', 'warning', 3000); return infobox.show('Erreur de connexion WebSocket@event', 'warning', 3000);
/* (3) If no message -> exit */ /* (3) If no message -> exit */
if( msg.msg == null ) if( msg.data == null )
return; return;
/* (4) Play sound if 1msg received + not already on page */ /* (4) Play sound if 1msg received + not already on page */
// note: 1msg means a new message but not the page load past buffer // note: 1msg means a new message but not the page load past buffer
if( msg.msg.length == 1 && router.app.$route.path != '/event' ) if( msg.data.length == 1 && router.app.$route.path != '/event' )
( new Audio('https://notificationsounds.com/message-tones/communication-channel-519/download/mp3') ).play(); ( new Audio('https://notificationsounds.com/message-tones/communication-channel-519/download/mp3') ).play();
/* (5) Add messages to stack */ /* (5) Add messages to stack */
gstore.data.notif.event.data = gstore.data.notif.event.data.concat( msg.msg ); gstore.data.notif.event.data = gstore.data.notif.event.data.concat( msg.data );
/* (6) Add notification count if not already on page */ /* (6) Add notification count if not already on page */
if( router.app.$route.path != '/event' ) if( router.app.$route.path != '/event' )
gstore.data.notif.event.count += msg.msg.length; gstore.data.notif.event.count += msg.data.length;
/* (7) Remove loader */ /* (7) Remove loader */
gstore.data.msg_pending.event = false; gstore.data.msg_pending.event = false;