0

I am developing an application to monitor routers using SNMP and Node.js. How can I make the data obtained through SNMP automatically refresh in the browser?

Note: I want the data to be refreshed automatically, without having to update the browser with F5. I'm using Node.js, Express and Socket.io.

Telecapp
  • 3
  • 1

1 Answers1

0

So what you could do is update it based on an event that happens in the backend.

Front End

<div id="updating">sample text</div>
<script>
  var updatedDiv = document.getElementById("updating")
  document.addEventListener("DOMContentLoaded", function(event) { 
    var socket = io();
    socket.on(‘update event’, data => {
      updatedDiv.innerHTML = data;
    });
  });
</script>

Back End

var io = require('socket.io')(http); 

function runme() {   
  io.emit(‘update event’,’this is the changed text’);
}

When the function is running, and the update event is running, the data in the html element will change. I hope that this solves your problem!

ca1c
  • 1,111
  • 10
  • 23