1.1.7-0 • Published 7 years ago
httping v1.1.7-0
Pinger
Setup
const Pinger = require('httping'),
pinger = new Pinger(url, [minimumInterval = 5000, maximumInterval = 5000, times = Infinity, protocol = "GET", callback = (...args) => { }]);
pinger.start();If maximumInterval and next parameters are not passed, maximumInterval is automatically set to minimumInterval's value and thus the pinging interval is fixed.
Properties/Methods
- ping(url = "localhost", meth = "GET", cb = () => {}) (static) -> Ping a specific url simultaneously.
- start() -> Start pinging. Throws an error if pinger is already active.
- stop() -> Stop pinging. Won't reset
times. - ping() -> Force-Ping (once, simultaneously).
- restart() ->
kill.stop(); ping.start(); - kill() -> Stops and resets timer.
All methods returnthisfor chaining apart fromping()'s that return aRequestobject.
This module creates the
hpingshortcut (optional) binary.
CLI
Pass pinger parameters either as environmental (url, inter, inter2, times, method) or as arguments (hping http://www.google.com 5000-6000 100 GET).
After invocing the command hping the cli accepts the following commands.
- stop|pause -> Pause pinger.
- exit|quit|close -> Close pinger.
- restart -> Start pinger.
- Everything else is
eval'd