Skip to content

Commit

Permalink
refactor(sparkplug): applied State pattern to SparkplugMqttClient, fi…
Browse files Browse the repository at this point in the history
…xed onConnectionLost status reset (#5114)

* refactor(sparkplug): applies State pattern to SparkplugMqttClient, fixed onConnectionLost status reset

Signed-off-by: Marcello Martina <[email protected]>

* style: fixed typo

Signed-off-by: Marcello Martina <[email protected]>

* style: fixed establish typo

Signed-off-by: Marcello Martina <[email protected]>

---------

Signed-off-by: Marcello Martina <[email protected]>
  • Loading branch information
marcellorinaldo authored Feb 3, 2024
1 parent 4fd0318 commit 7cac9e4
Show file tree
Hide file tree
Showing 2 changed files with 229 additions and 142 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public void connect() throws KuraConnectException {
throw new IllegalStateException("MQTT client is already connected");
}

this.client.estabilishSession(true);
this.client.establishSession(true);

stopExecutorService();
this.executorService = Executors.newSingleThreadExecutor();
Expand All @@ -149,7 +149,7 @@ public void connect() throws KuraConnectException {

@Override
public boolean isConnected() {
return Objects.nonNull(this.client) && this.client.isSessionEstabilished();
return Objects.nonNull(this.client) && this.client.isSessionEstablished();
}

@Override
Expand Down Expand Up @@ -230,8 +230,8 @@ public void removeDataTransportListener(DataTransportListener listener) {
@Override
public void connectionLost(Throwable arg0) {
logger.info("{} - Connection lost", this.kuraServicePid);
this.client.handleConnectionLost();
this.dataTransportListeners.forEach(listener -> callSafely(listener::onConnectionLost, arg0));

}

@Override
Expand Down
Loading

0 comments on commit 7cac9e4

Please sign in to comment.