2.0.7 • Published 5 years ago
betterpinger v2.0.7
betterpinger
A better solution for uptime by doing polling for server & client.
Table of Content
Installation
npm install betterpinger --saveDocs
core
A function that loaded via require("betterpinger"). To use this function, Put at request handler. Example:
server.on("request", core);core.connect
A function that connects to a server & communicate with your betterpinger server. In this function, You need to provide some parameters so it works perfectly. They are:
hostnameRequired for requesting to the provided hostname.portfor requesting to the different port of hostname.pathfor requesting to the provided path.headersfor setting this client headers.protocolfor requesting in different protocol.
core.connect events
connectevent will emitted when BetterPinger connected to your BetterPinger server.disconnectevent will emitted when BetterPinger disconnected from your BetterPinger Server.
Example
Server Example
const http = require("http");
const betterpinger = require("betterpinger");
http.createServer(betterpinger).listen(3000);Client Example
const { connect } = require("betterpinger");
connect({
hostname: "localhost",
port: 3000,
});