diff --git a/agents/meshcore.js b/agents/meshcore.js index 50f40117..7992b1c2 100644 --- a/agents/meshcore.js +++ b/agents/meshcore.js @@ -580,9 +580,9 @@ function getIpLocationDataEx(func) { // Remove all Gateway MAC addresses for interface list. This is useful because the gateway MAC is not always populated reliably. function clearGatewayMac(str) { - if (str == null) return null; + if (typeof str != 'string') return null; var x = JSON.parse(str); - for (var i in x.netif) { if (x.netif[i].gatewaymac) { delete x.netif[i].gatewaymac } } + for (var i in x.netif) { try { if (x.netif[i].gatewaymac) { delete x.netif[i].gatewaymac } } catch (ex) { } } return JSON.stringify(x); } @@ -4207,13 +4207,15 @@ function sendNetworkUpdateNagle() { if (sendNetworkUpdateNagleTimer != null) { c function sendNetworkUpdate(force) { sendNetworkUpdateNagleTimer = null; - // Update the network interfaces information data - var netInfo = { netif2: require('os').networkInterfaces() }; - if (netInfo.netif2) { - netInfo.action = 'netinfo'; - var netInfoStr = JSON.stringify(netInfo); - if ((force == true) || (clearGatewayMac(netInfoStr) != clearGatewayMac(lastNetworkInfo))) { mesh.SendCommand(netInfo); lastNetworkInfo = netInfoStr; } - } + try { + // Update the network interfaces information data + var netInfo = { netif2: require('os').networkInterfaces() }; + if (netInfo.netif2) { + netInfo.action = 'netinfo'; + var netInfoStr = JSON.stringify(netInfo); + if ((force == true) || (clearGatewayMac(netInfoStr) != clearGatewayMac(lastNetworkInfo))) { mesh.SendCommand(netInfo); lastNetworkInfo = netInfoStr; } + } + } catch (ex) { } } // Called periodically to check if we need to send updates to the server diff --git a/public/images/3dots-24.gif b/public/images/3dots-24.gif new file mode 100644 index 00000000..02cad79a Binary files /dev/null and b/public/images/3dots-24.gif differ diff --git a/public/images/3dots-48.gif b/public/images/3dots-48.gif new file mode 100644 index 00000000..7b63dba4 Binary files /dev/null and b/public/images/3dots-48.gif differ diff --git a/views/messenger.handlebars b/views/messenger.handlebars index 813c7e1a..9ac14ff7 100644 --- a/views/messenger.handlebars +++ b/views/messenger.handlebars @@ -29,13 +29,14 @@
+
- + @@ -83,6 +84,8 @@ if (webrtcconfiguration == '') { webrtcconfiguration = null; } else { try { webrtcconfiguration = JSON.parse(decodeURIComponent(webrtcconfiguration)); } catch (ex) { console.log('Invalid WebRTC config: "' + webrtcconfiguration + '".'); webrtcconfiguration = null; } } var windowFocus = true; var chatTextSession = new Date().toString() + '\r\n'; + var localOutText = false; + var remoteOutText = false; // File transfer state var fileUploads = []; @@ -136,6 +139,7 @@ // Backspace var outtext = Q('xouttext').value; if (outtext.length > 0) { Q('xouttext').value = outtext.substring(0, outtext.length - 1); } + updateLocalOutText(); } } if (userInputFocus == 0) { haltEvent(e); return false; } @@ -151,7 +155,7 @@ xsend(e); } else { // Any other key - if ((userInputFocus == 0) && (e.key.length == 1)) { Q('xouttext').value = Q('xouttext').value + e.key; } + if ((userInputFocus == 0) && (e.key.length == 1)) { Q('xouttext').value = Q('xouttext').value + e.key; updateLocalOutText(); } } } if (userInputFocus == 0) { haltEvent(e); return false; } @@ -233,6 +237,7 @@ if ((state == 2) || pushMessaging) { send({ action: 'chat', msg: outtext }); } Q('xouttext').value = ''; Q('xouttext').focus(); + localOutText = false; } } @@ -247,6 +252,7 @@ QV('camButton', webchannel && webchannel.ok && !localStream && (userMediaSupport == 2)); QV('micButton', webchannel && webchannel.ok && !localStream && (userMediaSupport > 0)); QV('hangupButton', webchannel && webchannel.ok && localStream); + updateLocalOutText(); } // This is the WebRTC setup @@ -345,6 +351,8 @@ if (socket != null) { socket.close(); socket = null; } updateControls(); state = 0; + updateLocalOutText(); + updateRemoteOutText(); } // Send data over the current transport (WebRTC first) @@ -372,7 +380,8 @@ try { data = JSON.parse(data); } catch (ex) { console.log('Unable to parse', data); return; } //console.log('RECV', data); switch (data.action) { - case 'chat': { displayRemote(data.msg); break; } // Incoming chat message. + case 'chat': { displayRemote(data.msg); updateRemoteOutText(false); break; } // Incoming chat message. + case 'outtext': { updateRemoteOutText(data.value); break; } case 'ctrl': { if (data.value == 1) { displayControl("Sent as push notification."); } else if (data.value == 2) { displayControl("Push notification failed."); } @@ -688,6 +697,8 @@ state = 2; updateControls(); sendws({ action: 'random', random: random }); // Send a random number. Higher number starts the WebRTC session. + updateLocalOutText(); + updateRemoteOutText(); return; } if (msg.data[0] == '{') { processMessage(msg.data, 1); } @@ -726,6 +737,23 @@ return r; } + function updateLocalOutText() { + var l = Q('xouttext').value; + if (((state != 2) || (l == '')) && (localOutText == true)) { + localOutText = false; + send({ action: 'outtext', value: false }); + } else if ((state == 2) && ((l != '') && (localOutText == false))) { + localOutText = true; + send({ action: 'outtext', value: true }); + } + } + + function updateRemoteOutText(newState) { + //console.log('updateRemoteOutText', newState); + if (state != 2) { newState = false; } + if (remoteOutText != newState) { remoteOutText = newState; QV('typingIndicator', remoteOutText); } + } +