[touchwand] Add port configuration to websocket (#13440)

* add port configuration to websocket

Signed-off-by: Roie Geron <roie.geron@gmail.com>
This commit is contained in:
Roie Geron 2022-09-26 20:05:50 +03:00 committed by GitHub
parent 517fe44b36
commit 58168c205f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View File

@ -85,7 +85,7 @@ public class TouchWandBridgeHandler extends BaseBridgeHandler implements TouchWa
updateStatus(ThingStatus.ONLINE);
synchronized (this) {
if (isRunning) {
TouchWandWebSockets localSockets = touchWandWebSockets = new TouchWandWebSockets(host,
TouchWandWebSockets localSockets = touchWandWebSockets = new TouchWandWebSockets(host, port,
scheduler);
localSockets.registerListener(this);
localSockets.connect();

View File

@ -59,6 +59,7 @@ public class TouchWandWebSockets {
private WebSocketClient client;
private String controllerAddress;
private int port;
private TouchWandSocket touchWandSocket;
private boolean isShutDown = false;
private CopyOnWriteArraySet<TouchWandUnitStatusUpdateListener> listeners = new CopyOnWriteArraySet<>();
@ -67,17 +68,18 @@ public class TouchWandWebSockets {
private ScheduledExecutorService scheduler;
public TouchWandWebSockets(String ipAddress, ScheduledExecutorService scheduler) {
public TouchWandWebSockets(String ipAddress, int port, ScheduledExecutorService scheduler) {
client = new WebSocketClient();
touchWandSocket = new TouchWandSocket();
this.controllerAddress = ipAddress;
this.port = port;
this.scheduler = scheduler;
socketReconnect = null;
}
public void connect() {
try {
uri = new URI("ws://" + controllerAddress + WS_ENDPOINT_TOUCHWAND);
uri = new URI("ws://" + controllerAddress + ":" + String.valueOf(port) + WS_ENDPOINT_TOUCHWAND);
} catch (URISyntaxException e) {
logger.warn("URI not valid {} message {}", uri, e.getMessage());
return;