Skip to content

Commit

Permalink
Fix the old websocket API
Browse files Browse the repository at this point in the history
  • Loading branch information
ashvayka committed Feb 16, 2024
1 parent 4488035 commit 2e57990
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,8 @@ private void handleWsAlarmCountCmd(WebSocketSessionRef sessionRef, AlarmCountCmd

@Override
public void sendUpdate(String sessionId, int cmdId, TelemetrySubscriptionUpdate update) {
doSendUpdate(sessionId, cmdId, update);
// We substitute the subscriptionId with cmdId for old-style subscriptions.
doSendUpdate(sessionId, cmdId, update.copyWithNewSubscriptionId(cmdId));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.thingsboard.server.service.ws.telemetry.sub;

import lombok.AllArgsConstructor;
import org.thingsboard.server.common.data.kv.TsKvEntry;
import org.thingsboard.server.service.subscription.SubscriptionErrorCode;

Expand All @@ -26,8 +27,8 @@
import java.util.TreeMap;
import java.util.stream.Collectors;

@AllArgsConstructor
public class TelemetrySubscriptionUpdate {

private final int subscriptionId;
private int errorCode;
private String errorMsg;
Expand Down Expand Up @@ -93,6 +94,10 @@ public String getErrorMsg() {
return errorMsg;
}

public TelemetrySubscriptionUpdate copyWithNewSubscriptionId(int subscriptionId){
return new TelemetrySubscriptionUpdate(subscriptionId, errorCode, errorMsg, data);
}

@Override
public String toString() {
StringBuilder result = new StringBuilder("TelemetrySubscriptionUpdate [subscriptionId=" + subscriptionId + ", errorCode=" + errorCode + ", errorMsg=" + errorMsg + ", data=");
Expand Down

0 comments on commit 2e57990

Please sign in to comment.