NetworkMonitor

NetworkMonitor

A connection to the network monitor running on an instance.

Instances of this class are returned from Instance#networkMonitor and Instance#newNetworkMonitor. They should not be created using the constructor.

Methods

(async) clearLog()

Description:
  • Clear captured Network Monitor data

Source:
Example
let netmon = await instance.newNetworkMonitor();
netmon.clearLog();

disconnect()

Description:
  • Disconnect an network monitor connection. This is usually only required if a new network monitor connection has been created and is no longer needed

Source:
Example
netmon.disconnect();

(async) handleMessage(handler)

Description:
  • Set message handler

Source:
Example
let netmon = await instance.newNetworkMonitor();
netmon.handleMessage((message) => {
    let host = message.request.headers.find(entry => entry.key === 'Host');
    console.log(message.response.status, message.request.method, message.response.body.size, host.value);
});
Parameters:
Name Type Description
handler NetworkMonitor~newEntryCallback

the callback for captured entry

(async) isEnabled() → {boolean}

Description:
  • Check if Network Monitor is enabled

Source:
Example
let enabled = await netmon.isEnabled();
if (enabled) {
    console.log("enabled");
} else {
    console.log("disabled");
}
Returns:
Type
boolean

(async) start(options)

Description:
  • Start Network Monitor

Source:
Example
let netmon = await instance.newNetworkMonitor();
netmon.start({ truncatePcap: true });
Parameters:
Name Type Description
options StartOptions

(async) stop()

Description:
  • Stop Network Monitor

Source:
Example
let netmon = await instance.newNetworkMonitor();
netmon.stop();

Type Definitions

newEntryCallback(entry)

Description:
Source:
Example
let netmon = await instance.newNetworkMonitor();
netmon.handleMessage((message) => {
    let host = message.request.headers.find(entry => entry.key === 'Host');
    console.log(message.response.status, message.request.method, message.response.body.size, host.value);
});
Parameters:
Name Type Description
entry NetmonEntry

NetmonEntry object.