100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps
Java asset-managementbuildingdashboarddataplatformdevice-managementedge-computingenergyenergy-managementenergy-monitorfleet-managementfleet-telematicsiotiot-applicationiot-platformmodbusmqttmqtt-brokerota-updaterules-enginesmartcity
Removed RenewEventSubscriptions (subscriptions are kept until clients disconnect so renew is obsolete)
Rich Turner1ffbfe0220ae
diff --git a/model/src/main/java/org/openremote/model/event/shared/RenewEventSubscriptions.java b/model/src/main/java/org/openremote/model/event/shared/RenewEventSubscriptions.javadeleted file mode 100644index 7457ea64a..000000000--- a/model/src/main/java/org/openremote/model/event/shared/RenewEventSubscriptions.java+++ /dev/null@@ -1,39 +0,0 @@-/*- * Copyright 2019, OpenRemote Inc.- *- * See the CONTRIBUTORS.txt file in the distribution for a- * full listing of individual contributors.- *- * This program is free software: you can redistribute it and/or modify- * it under the terms of the GNU Affero General Public License as- * published by the Free Software Foundation, either version 3 of the- * License, or (at your option) any later version.- *- * This program is distributed in the hope that it will be useful,- * but WITHOUT ANY WARRANTY; without even the implied warranty of- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- * GNU Affero General Public License for more details.- *- * You should have received a copy of the GNU Affero General Public License- * along with this program. If not, see <http://www.gnu.org/licenses/>.- */-package org.openremote.model.event.shared;--import com.fasterxml.jackson.annotation.JsonCreator;-import com.fasterxml.jackson.annotation.JsonProperty;--public class RenewEventSubscriptions {-- public static final String MESSAGE_PREFIX = "RENEW:";-- protected String[] subscriptionIds;-- @JsonCreator- public RenewEventSubscriptions(@JsonProperty("subscriptionIds") String[] subscriptionIds) {- this.subscriptionIds = subscriptionIds;- }-- public String[] getSubscriptionIds() {- return subscriptionIds;- }-}diff --git a/ui/component/core/src/event.ts b/ui/component/core/src/event.tsindex 965a7b338..15b7305ec 100644--- a/ui/component/core/src/event.ts+++ b/ui/component/core/src/event.ts@@ -4,7 +4,6 @@ import {AttributeEvent,CancelEventSubscription,EventSubscription,- RenewEventSubscriptions,SharedEvent,AssetEvent,TriggeredEventSubscription,@@ -60,7 +59,6 @@ interface EventSubscriptionInfo<T extends SharedEvent> {const SUBSCRIBE_MESSAGE_PREFIX = "SUBSCRIBE:";const SUBSCRIBED_MESSAGE_PREFIX = "SUBSCRIBED:";const UNSUBSCRIBE_MESSAGE_PREFIX = "UNSUBSCRIBE:";-const RENEW_MESSAGE_PREFIX = "RENEW:";const UNAUTHORIZED_MESSAGE_PREFIX = "UNAUTHORIZED:";const TRIGGERED_MESSAGE_PREFIX = "TRIGGERED:";const EVENT_MESSAGE_PREFIX = "EVENT:";@@ -493,14 +491,12 @@ abstract class EventProviderImpl implements EventProvider {export class WebSocketEventProvider extends EventProviderImpl {protected static _subscriptionCounter: number = 1;- protected static _subscriptionRenewalMillis = 150 * 1000;private readonly _endpointUrl: string;protected _webSocket: WebSocket | undefined = undefined;protected _connectDeferred: Deferred<boolean> | null = null;protected _subscribeDeferred: Deferred<string> | null = null;protected _repliesDeferred: Map<string, Deferred<SharedEvent>> = new Map<string, Deferred<SharedEvent>>();- protected _renewalTimer: number | null = null;get endpointUrl(): string {return this._endpointUrl;@@ -565,14 +561,6 @@ export class WebSocketEventProvider extends EventProviderImpl {if (msg && msg.startsWith(SUBSCRIBED_MESSAGE_PREFIX)) {const jsonStr = msg.substring(SUBSCRIBED_MESSAGE_PREFIX.length);const subscription = JSON.parse(jsonStr) as EventSubscription<SharedEvent>;-- // Create a renewal timer if not done so- if (!this._renewalTimer) {- setInterval(() => {- this._doRenewal();- }, WebSocketEventProvider._subscriptionRenewalMillis);- }-const deferred = this._subscribeDeferred;this._subscribeDeferred = null;if (deferred) {@@ -612,10 +600,6 @@ export class WebSocketEventProvider extends EventProviderImpl {}protected _beforeDisconnect(): void {- if (this._renewalTimer != null) {- clearInterval(this._renewalTimer);- this._renewalTimer = null;- }this._onDisconnect();}@@ -648,20 +632,6 @@ export class WebSocketEventProvider extends EventProviderImpl {subscriptionId: subscriptionId};this._webSocket.send(UNSUBSCRIBE_MESSAGE_PREFIX + JSON.stringify(cancelSubscription));- if (Object.keys(this._subscriptionMap).length === 0 && this._renewalTimer) {- clearInterval(this._renewalTimer);- }- }-- protected _doRenewal() {- if (!this._webSocket) {- return;- }-- const renewSubscriptions: RenewEventSubscriptions = {- subscriptionIds: Object.keys(this._subscriptionMap)- };- this._webSocket.send(RENEW_MESSAGE_PREFIX + JSON.stringify(renewSubscriptions));}protected _doSend<T extends SharedEvent>(event: T): void {