}
}
+ public void close() {
+ try {
+ if (client.isRunning()) {
+ client.stop();
+ }
+ } catch (Exception e) {
+ logger.warn("An exception occurred while stopping the WebSocket client : {}", e.getMessage());
+ }
+ }
+
public void connect(URI endpointURI) {
if (connectionState == ConnectionState.CONNECTED) {
return;
this.session = session;
}
- public void close() {
+ public void closeConnection() {
try {
connectionState = ConnectionState.CLOSING;
if (session != null && session.isOpen()) {
}
if (systemTimeStamp - currentTimeStamp > EVENT_TIMESTAMP_MAX_DELTA) {
logger.trace("Event : The event endpoint will be reset");
- eventEndpoint.close();
+ eventEndpoint.closeConnection();
}
}
break;
case "data:error":
logger.debug("Event : Received an error: '{}'/'{}'", event.value, event.error_type);
- eventEndpoint.close();
+ eventEndpoint.closeConnection();
break;
}
}
"Event : Reached the maximum number of errors ({}) for the current interval ({} seconds)",
EVENT_MAXIMUM_ERRORS_IN_INTERVAL, EVENT_ERROR_INTERVAL_SECONDS);
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR);
- eventEndpoint.close();
+ eventEndpoint.closeConnection();
}
if ((System.currentTimeMillis() - eventIntervalTimestamp) > 1000
if (Thread.interrupted()) {
logger.debug("Event : The event thread was interrupted");
+ eventEndpoint.close();
return;
}
}