mirror of
https://github.com/esiur/esiur-dart.git
synced 2025-09-13 12:03:18 +00:00
wsUrl
This commit is contained in:
@@ -217,11 +217,14 @@ class DistributedConnection extends NetworkConnection implements IStore {
|
|||||||
|
|
||||||
var domain = instance?.attributes["domain"].toString() ?? address;
|
var domain = instance?.attributes["domain"].toString() ?? address;
|
||||||
|
|
||||||
|
|
||||||
var ws = instance?.attributes.containsKey("ws") == true ||
|
var ws = instance?.attributes.containsKey("ws") == true ||
|
||||||
instance?.attributes.containsKey("wss") == true;
|
instance?.attributes.containsKey("wss") == true;
|
||||||
var secure = instance?.attributes.containsKey("secure") == true ||
|
var secure = instance?.attributes.containsKey("secure") == true ||
|
||||||
instance?.attributes.containsKey("wss") == true;
|
instance?.attributes.containsKey("wss") == true;
|
||||||
|
|
||||||
|
var wsUrl = instance?.attributes["wsUrl"].toString() ?? "";
|
||||||
|
|
||||||
if (instance?.attributes.containsKey("autoReconnect") ?? false)
|
if (instance?.attributes.containsKey("autoReconnect") ?? false)
|
||||||
autoReconnect = instance?.attributes["autoReconnect"] == true;
|
autoReconnect = instance?.attributes["autoReconnect"] == true;
|
||||||
|
|
||||||
@@ -248,6 +251,7 @@ class DistributedConnection extends NetworkConnection implements IStore {
|
|||||||
passwordOrToken: password,
|
passwordOrToken: password,
|
||||||
username: username,
|
username: username,
|
||||||
useWebsocket: ws,
|
useWebsocket: ws,
|
||||||
|
wsUrl: wsUrl,
|
||||||
secureWebSocket: secure);
|
secureWebSocket: secure);
|
||||||
} else if (instance?.attributes.containsKey("token") == true) {
|
} else if (instance?.attributes.containsKey("token") == true) {
|
||||||
var token =
|
var token =
|
||||||
@@ -286,7 +290,8 @@ class DistributedConnection extends NetworkConnection implements IStore {
|
|||||||
DC? passwordOrToken,
|
DC? passwordOrToken,
|
||||||
String? domain,
|
String? domain,
|
||||||
bool useWebsocket = false,
|
bool useWebsocket = false,
|
||||||
bool secureWebSocket = false}) {
|
bool secureWebSocket = false,
|
||||||
|
String wsUrl = ""}) {
|
||||||
if (_openReply != null)
|
if (_openReply != null)
|
||||||
throw AsyncException(ErrorType.Exception, 0, "Connection in progress");
|
throw AsyncException(ErrorType.Exception, 0, "Connection in progress");
|
||||||
|
|
||||||
@@ -321,7 +326,7 @@ class DistributedConnection extends NetworkConnection implements IStore {
|
|||||||
|
|
||||||
if (socket == null) {
|
if (socket == null) {
|
||||||
if (useWebsocket || kIsWeb) {
|
if (useWebsocket || kIsWeb) {
|
||||||
socket = new WSocket()..secure = secureWebSocket;
|
socket = WSocket() .. secure = true .. wsUrl = wsUrl;
|
||||||
} else
|
} else
|
||||||
socket = new TCPSocket();
|
socket = new TCPSocket();
|
||||||
}
|
}
|
||||||
|
@@ -50,6 +50,8 @@ class WSocket extends ISocket {
|
|||||||
|
|
||||||
IPEndPoint? _localEP, _remoteEP;
|
IPEndPoint? _localEP, _remoteEP;
|
||||||
|
|
||||||
|
String wsUrl = "";
|
||||||
|
|
||||||
bool begin() {
|
bool begin() {
|
||||||
if (began) return false;
|
if (began) return false;
|
||||||
|
|
||||||
@@ -100,7 +102,7 @@ class WSocket extends ISocket {
|
|||||||
_state = SocketState.Connecting;
|
_state = SocketState.Connecting;
|
||||||
|
|
||||||
_channel = WebSocketChannel.connect(
|
_channel = WebSocketChannel.connect(
|
||||||
Uri.parse("${secure ? 'wss' : 'ws'}://${hostname}:${port}"),
|
Uri.parse("${secure ? 'wss' : 'ws'}://${hostname}:${port}/${wsUrl}"),
|
||||||
); //binaryType: BinaryType.list);
|
); //binaryType: BinaryType.list);
|
||||||
|
|
||||||
if (_channel == null)
|
if (_channel == null)
|
||||||
|
Reference in New Issue
Block a user