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()

Source:

Clear captured Network Monitor data

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

disconnect()

Source:

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

Example
netmon.disconnect();

(async) handleMessage(handler)

Source:

Set message handler

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}

Source:

Check if Network Monitor is enabled

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

(async) start()

Source:

Start Network Monitor

Example
let netmon = await instance.newNetworkMonitor();
netmon.start();

(async) stop()

Source:

Stop Network Monitor

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

Type Definitions

newEntryCallback(entry)

Source:

A callback for file upload progress messages. Can be passed to NetworkMonitor#handleMessage

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.