Miss any of our Open RFC calls?Watch the recordings here! »

@bugsounet/internet

1.0.0 • Public • Published

internet

single node routine for checking internet status

Installation

npm install @bugsounet/internet

Sample with pir contructor

const Internet = require("@bugsounet/internet")
 
this.config = {
  delay: 10 * 1000,
  scan: "google.com",
  command: "pm2 restart 0",
  showAlert: true
}
 
var debug = true
 
this.internet = new Internet(this.config, callback, debug)
this.internet.start()
setTimeout(() => { this.internet.stop() } , 60 * 1000)
 
function callback(status, value) {
  if (status == "INTERNET_PING") console.log ("Ping:", value)
  if (status == "INTERNET_DOWN") console.log ("Conexion lost... Retry:", value)
  if (status == "INTERNET_RESTART") console.log ("Internet is back")
}

constructor of internet

internet(internetConfig, callback, debug)

internetConfig {}

  • delay - set the interval for internet checking.
  • scan - ping point name or address.
  • command - command to execute when internet afresh available
  • showAlert - send a callback Alert about internet connection lost and available

callback (status,value)

  • INTERNET_PING - return current ping with value
  • INTERNET_DOWN - return internet down status with number of retry in value
  • INTERNET_RESTART- return internet available status

INTERNET_DOWN and INTERNET_RESTART will be sended only if showAlert feature is enable

debug

if you want debuging information, just set to true

Functions

  • start() : start internet scan
  • stop() : force stop scan

Keywords

Install

npm i @bugsounet/internet

DownloadsWeekly Downloads

49

Version

1.0.0

License

MIT

Unpacked Size

7.48 kB

Total Files

6

Last publish

Collaborators

  • avatar