From 693367f62615a67b0d5a87642ea75bfa65fdf1dd Mon Sep 17 00:00:00 2001 From: Ahmed Zamil Date: Wed, 23 Jul 2025 20:54:10 +0300 Subject: [PATCH] wsUrl --- lib/src/Net/IIP/DistributedConnection.dart | 9 +++++++-- lib/src/Net/Sockets/WSocket.dart | 4 +++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/src/Net/IIP/DistributedConnection.dart b/lib/src/Net/IIP/DistributedConnection.dart index 3c7375a..9e2a633 100644 --- a/lib/src/Net/IIP/DistributedConnection.dart +++ b/lib/src/Net/IIP/DistributedConnection.dart @@ -217,11 +217,14 @@ class DistributedConnection extends NetworkConnection implements IStore { var domain = instance?.attributes["domain"].toString() ?? address; + var ws = instance?.attributes.containsKey("ws") == true || instance?.attributes.containsKey("wss") == true; var secure = instance?.attributes.containsKey("secure") == true || instance?.attributes.containsKey("wss") == true; + var wsUrl = instance?.attributes["wsUrl"].toString() ?? ""; + if (instance?.attributes.containsKey("autoReconnect") ?? false) autoReconnect = instance?.attributes["autoReconnect"] == true; @@ -248,6 +251,7 @@ class DistributedConnection extends NetworkConnection implements IStore { passwordOrToken: password, username: username, useWebsocket: ws, + wsUrl: wsUrl, secureWebSocket: secure); } else if (instance?.attributes.containsKey("token") == true) { var token = @@ -286,7 +290,8 @@ class DistributedConnection extends NetworkConnection implements IStore { DC? passwordOrToken, String? domain, bool useWebsocket = false, - bool secureWebSocket = false}) { + bool secureWebSocket = false, + String wsUrl = ""}) { if (_openReply != null) throw AsyncException(ErrorType.Exception, 0, "Connection in progress"); @@ -321,7 +326,7 @@ class DistributedConnection extends NetworkConnection implements IStore { if (socket == null) { if (useWebsocket || kIsWeb) { - socket = new WSocket()..secure = secureWebSocket; + socket = WSocket() .. secure = true .. wsUrl = wsUrl; } else socket = new TCPSocket(); } diff --git a/lib/src/Net/Sockets/WSocket.dart b/lib/src/Net/Sockets/WSocket.dart index d95b6fe..1e2715d 100644 --- a/lib/src/Net/Sockets/WSocket.dart +++ b/lib/src/Net/Sockets/WSocket.dart @@ -50,6 +50,8 @@ class WSocket extends ISocket { IPEndPoint? _localEP, _remoteEP; + String wsUrl = ""; + bool begin() { if (began) return false; @@ -100,7 +102,7 @@ class WSocket extends ISocket { _state = SocketState.Connecting; _channel = WebSocketChannel.connect( - Uri.parse("${secure ? 'wss' : 'ws'}://${hostname}:${port}"), + Uri.parse("${secure ? 'wss' : 'ws'}://${hostname}:${port}/${wsUrl}"), ); //binaryType: BinaryType.list); if (_channel == null)