diff --git a/src/incoming-requests.ts b/src/incoming-requests.ts index b4df313..9c3d375 100644 --- a/src/incoming-requests.ts +++ b/src/incoming-requests.ts @@ -97,8 +97,10 @@ export class IncomingRequests { async handle(pduObj: PduObject): Promise { const generation = this.linkGeneration; + const { onRequest } = this; - if (this.onRequest && await this.onRequest(this.session, pduObj)) return; + // Called unbound, so the application's hook never sees this class as its `this`. + if (onRequest && await onRequest(this.session, pduObj)) return; // The link it arrived on went while the hook ran, so nothing we answer now correlates. if (this.linkGeneration !== generation) {