From d7162c327183fb8ea9ad2e03facf700319b11b5b Mon Sep 17 00:00:00 2001 From: Luc Heaton Date: Mon, 18 Nov 2024 19:53:18 +0100 Subject: [PATCH] fix: add rinfo to UDPHelper message event (#103) --- src/helpers/udp.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/helpers/udp.ts b/src/helpers/udp.ts index a71d4ab..c146e51 100644 --- a/src/helpers/udp.ts +++ b/src/helpers/udp.ts @@ -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] @@ -119,7 +119,8 @@ export class UDPHelper extends EventEmitter { 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')) {