Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Rename complete event -> end #303

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,13 @@ If you no longer need to receive packets, you can use `pcap_session.close()`.
To read packets from a file instead of from a live interface, use `createOfflineSession` instead:

```javascript
pcap.createOfflineSession('/path/to/capture.pcap', options);
const pcap_session = pcap.createOfflineSession('/path/to/capture.pcap', options);
pcap_session.on('packet', function (raw_packet) {
// do some stuff with a raw packet
});
pcap_session.on('end', function () {
// do some stuff when file ends
});
```

Where `options` only accepts the `filter` property.
Expand Down
4 changes: 0 additions & 4 deletions examples/tcp_metrics
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ pcap_session.on("packet", function (raw_packet) {
tcp_tracker.track_packet(packet);
});

pcap_session.on("complete", function () {
console.log("pcap session complete.");
});

// tracker emits sessions, and sessions emit data
tcp_tracker.on("session", function (session) {
console.log("Start of TCP session between " + session.src_name + " and " + session.dst_name);
Expand Down
1 change: 1 addition & 0 deletions pcap.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ function PcapSession(is_live, device_name, filter, buffer_size, snap_length, out
do {
packets = this.session.dispatch(this.buf, this.header);
} while ( packets > 0 );
this.emit("end");
this.emit("complete");
});
}
Expand Down