diff --git a/packages/binding-coap/src/coap-server.ts b/packages/binding-coap/src/coap-server.ts index d31acfa72..f05e62769 100644 --- a/packages/binding-coap/src/coap-server.ts +++ b/packages/binding-coap/src/coap-server.ts @@ -698,10 +698,10 @@ export default class CoapServer implements ProtocolServer { res.on("finish", (err: Error) => { error(`CoapServer on port ${this.port} failed on observe with: ${err.message}`); - thing.handleUnobserveProperty(affordanceKey, listener, interactionOptions); + void thing.handleUnobserveProperty(affordanceKey, listener, interactionOptions); }); - setTimeout(() => thing.handleUnobserveProperty(affordanceKey, listener, interactionOptions), 60 * 60 * 1000); + setTimeout(() => void thing.handleUnobserveProperty(affordanceKey, listener, interactionOptions), 60 * 60 * 1000); } private createContentListener( @@ -886,7 +886,7 @@ export default class CoapServer implements ProtocolServer { req.rsinfo.address )}:${req.rsinfo.port}` ); - thing.handleUnsubscribeEvent(affordanceKey, listener, interactionOptions); + void thing.handleUnsubscribeEvent(affordanceKey, listener, interactionOptions); }); } else if (observe > 0) { debug( diff --git a/packages/binding-http/src/routes/event.ts b/packages/binding-http/src/routes/event.ts index 91a29de3b..e342a333a 100644 --- a/packages/binding-http/src/routes/event.ts +++ b/packages/binding-http/src/routes/event.ts @@ -86,7 +86,7 @@ export default async function eventRoute( } catch (err) { // Safe cast to NodeJS.ErrnoException we are checking if it is equal to ERR_HTTP_HEADERS_SENT if ((err as NodeJS.ErrnoException)?.code === "ERR_HTTP_HEADERS_SENT") { - thing.handleUnsubscribeEvent(eventName, listener, options); + void thing.handleUnsubscribeEvent(eventName, listener, options); return; } const message = err instanceof Error ? err.message : JSON.stringify(err); @@ -99,9 +99,9 @@ export default async function eventRoute( await thing.handleSubscribeEvent(eventName, listener, options); res.on("close", () => { debug(`HttpServer on port ${this.getPort()} closed Event connection`); - thing.handleUnsubscribeEvent(eventName, listener, options); + void thing.handleUnsubscribeEvent(eventName, listener, options); }); - res.setTimeout(60 * 60 * 1000, () => thing.handleUnsubscribeEvent(eventName, listener, options)); + res.setTimeout(60 * 60 * 1000, () => void thing.handleUnsubscribeEvent(eventName, listener, options)); } else if (req.method === "HEAD") { // HEAD support for long polling subscription res.writeHead(202); diff --git a/packages/binding-http/src/routes/property-observe.ts b/packages/binding-http/src/routes/property-observe.ts index 1c2aac2cc..e8cb2ca60 100644 --- a/packages/binding-http/src/routes/property-observe.ts +++ b/packages/binding-http/src/routes/property-observe.ts @@ -88,7 +88,7 @@ export default async function propertyObserveRoute( } catch (err) { // Safe cast to NodeJS.ErrnoException we are checking if it is equal to ERR_HTTP_HEADERS_SENT if ((err as NodeJS.ErrnoException)?.code === "ERR_HTTP_HEADERS_SENT") { - thing.handleUnobserveProperty(propertyName, listener, options); + void thing.handleUnobserveProperty(propertyName, listener, options); return; } const message = err instanceof Error ? err.message : JSON.stringify(err); @@ -104,9 +104,9 @@ export default async function propertyObserveRoute( await thing.handleObserveProperty(_params.property, listener, options); res.on("finish", () => { debug(`HttpServer on port ${this.getPort()} closed connection`); - thing.handleUnobserveProperty(propertyName, listener, options); + void thing.handleUnobserveProperty(propertyName, listener, options); }); - res.setTimeout(60 * 60 * 1000, () => thing.handleUnobserveProperty(propertyName, listener, options)); + res.setTimeout(60 * 60 * 1000, () => void thing.handleUnobserveProperty(propertyName, listener, options)); } else if (req.method === "HEAD") { // HEAD support for long polling subscription // TODO: set the Content-Type header to the type of the property diff --git a/packages/binding-mqtt/src/mqtt-broker-server.ts b/packages/binding-mqtt/src/mqtt-broker-server.ts index 810f3fddc..c1250a6c0 100644 --- a/packages/binding-mqtt/src/mqtt-broker-server.ts +++ b/packages/binding-mqtt/src/mqtt-broker-server.ts @@ -195,7 +195,7 @@ export default class MqttBrokerServer implements ProtocolServer { if (content == null) { warn(`MqttBrokerServer on port ${this.getPort()} cannot process data for Event ${eventName}`); - thing.handleUnsubscribeEvent(eventName, eventListener, { formIndex: event.forms.length - 1 }); + void thing.handleUnsubscribeEvent(eventName, eventListener, { formIndex: event.forms.length - 1 }); return; } debug(`MqttBrokerServer at ${this.brokerURI} publishing to Event topic '${eventName}' `); diff --git a/packages/binding-websockets/src/ws-server.ts b/packages/binding-websockets/src/ws-server.ts index bf45342bf..69c357ffd 100644 --- a/packages/binding-websockets/src/ws-server.ts +++ b/packages/binding-websockets/src/ws-server.ts @@ -233,7 +233,7 @@ export default class WebSocketServer implements ProtocolServer { ws.on("close", () => { for (let formIndex = 0; formIndex < thing.properties[propertyName].forms.length; formIndex++) { - thing.handleUnobserveProperty(propertyName, observeListener, { formIndex }); + void thing.handleUnobserveProperty(propertyName, observeListener, { formIndex }); } debug( `WebSocketServer on port ${this.getPort()} closed connection for '${path}' from ${Helpers.toUriLiteral( @@ -293,7 +293,7 @@ export default class WebSocketServer implements ProtocolServer { ws.on("close", () => { for (let formIndex = 0; formIndex < event.forms.length; formIndex++) { - thing.handleUnsubscribeEvent(eventName, eventListener, { formIndex }); + void thing.handleUnsubscribeEvent(eventName, eventListener, { formIndex }); } debug( `WebSocketServer on port ${this.getPort()} closed connection for '${path}' from ${Helpers.toUriLiteral( diff --git a/packages/core/src/exposed-thing.ts b/packages/core/src/exposed-thing.ts index 51401068d..935a090c6 100644 --- a/packages/core/src/exposed-thing.ts +++ b/packages/core/src/exposed-thing.ts @@ -572,11 +572,11 @@ export default class ExposedThing extends TD.Thing implements WoT.ExposedThing { * * @experimental */ - public handleUnsubscribeEvent( + public async handleUnsubscribeEvent( name: string, listener: ContentListener, options: WoT.InteractionOptions & { formIndex: number } - ): void { + ): Promise { if (this.events[name] != null) { Helpers.validateInteractionOptions(this, this.events[name], options); @@ -595,7 +595,7 @@ export default class ExposedThing extends TD.Thing implements WoT.ExposedThing { } const unsubscribe = this.#eventHandlers.get(name)?.unsubscribe; if (unsubscribe) { - unsubscribe(options); + await unsubscribe(options); } debug(`ExposedThing '${this.title}' unsubscribes from event '${name}'`); } else { @@ -639,11 +639,11 @@ export default class ExposedThing extends TD.Thing implements WoT.ExposedThing { } } - public handleUnobserveProperty( + public async handleUnobserveProperty( name: string, listener: ContentListener, options: WoT.InteractionOptions & { formIndex: number } - ): void { + ): Promise { if (this.properties[name] != null) { Helpers.validateInteractionOptions(this, this.properties[name], options); const formIndex = ProtocolHelpers.getFormIndexForOperation( @@ -663,7 +663,7 @@ export default class ExposedThing extends TD.Thing implements WoT.ExposedThing { const unobserveHandler = this.#propertyHandlers.get(name)?.unobserveHandler; if (unobserveHandler) { - unobserveHandler(options); + await unobserveHandler(options); } } else { throw new Error(`ExposedThing '${this.title}', no property found for '${name}'`);