Merge pull request #2838 from 21pages/switch_sides

switch sides
This commit is contained in:
RustDesk
2023-01-21 08:05:32 +08:00
committed by GitHub
60 changed files with 565 additions and 183 deletions

View File

@@ -1261,23 +1261,28 @@ StreamSubscription? listenUniLinks() {
/// Returns true if we successfully handle the startup arguments.
bool checkArguments() {
// bootArgs:[--connect, 362587269, --switch_uuid, e3d531cc-5dce-41e0-bd06-5d4a2b1eec05]
// check connect args
final connectIndex = bootArgs.indexOf("--connect");
if (connectIndex == -1) {
return false;
}
String? arg =
String? id =
bootArgs.length < connectIndex + 1 ? null : bootArgs[connectIndex + 1];
if (arg != null) {
if (arg.startsWith(kUniLinksPrefix)) {
return parseRustdeskUri(arg);
final switchUuidIndex = bootArgs.indexOf("--switch_uuid");
String? switchUuid = bootArgs.length < switchUuidIndex + 1
? null
: bootArgs[switchUuidIndex + 1];
if (id != null) {
if (id.startsWith(kUniLinksPrefix)) {
return parseRustdeskUri(id);
} else {
// remove "--connect xxx" in the `bootArgs` array
bootArgs.removeAt(connectIndex);
bootArgs.removeAt(connectIndex);
// fallback to peer id
Future.delayed(Duration.zero, () {
rustDeskWinManager.newRemoteDesktop(arg);
rustDeskWinManager.newRemoteDesktop(id, switch_uuid: switchUuid);
});
return true;
}
@@ -1307,8 +1312,10 @@ bool callUniLinksUriHandler(Uri uri) {
// new connection
if (uri.authority == "connection" && uri.path.startsWith("/new/")) {
final peerId = uri.path.substring("/new/".length);
var param = uri.queryParameters;
String? switch_uuid = param["switch_uuid"];
Future.delayed(Duration.zero, () {
rustDeskWinManager.newRemoteDesktop(peerId);
rustDeskWinManager.newRemoteDesktop(peerId, switch_uuid: switch_uuid);
});
return false;
}
@@ -1606,3 +1613,7 @@ Widget dialogButton(String text,
));
}
}
int version_cmp(String v1, String v2) {
return bind.versionToNumber(v: v1) - bind.versionToNumber(v: v2);
}