Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

fix: add rinfo to UDPHelper message event #103

Merged
merged 6 commits into from
Nov 18, 2024
Merged
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
5 changes: 3 additions & 2 deletions src/helpers/udp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export interface UDPHelperEvents {
// the socket is listening for packets
listening: []
// a packet of data has been received
data: [msg: Buffer]
data: [msg: Buffer, rinfo: dgram.RemoteInfo]

// the connection status changes
status_change: [status: UDPStatuses, message: string | undefined]
Expand Down Expand Up @@ -119,7 +119,8 @@ export class UDPHelper extends EventEmitter<UDPHelperEvents> {
this.emit('listening')
})

this.#socket.on('message', (data) => this.emit('data', data))
// Passing on rinfo to emit instead of omitting it
this.#socket.on('message', (data, rinfo) => this.emit('data', data, rinfo))

this.#missingErrorHandlerTimer = setTimeout(() => {
if (!this.#destroyed && !this.listenerCount('error')) {
Expand Down