Skip to content

Commit

Permalink
fix: add rinfo to UDPHelper message event (#103)
Browse files Browse the repository at this point in the history
  • Loading branch information
Luuccc authored Nov 18, 2024
1 parent cfb2a75 commit d7162c3
Showing 1 changed file with 3 additions and 2 deletions.
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

0 comments on commit d7162c3

Please sign in to comment.