switch sides

Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
21pages
2023-01-17 13:28:33 +08:00
parent 45c0e10102
commit 333092f983
49 changed files with 373 additions and 61 deletions

View File

@@ -199,6 +199,16 @@ class FfiModel with ChangeNotifier {
parent.target?.serverModel.setShowElevation(show);
} else if (name == 'cancel_msgbox') {
cancelMsgBox(evt, peerId);
} else if (name == 'switch_sides') {
final peer_id = evt['peer_id'].toString();
final uuid = evt['uuid'].toString();
Future.delayed(Duration.zero, () {
rustDeskWinManager.newRemoteDesktop(peer_id, switch_uuid: uuid);
});
} else if (name == 'switch_back') {
final peer_id = evt['peer_id'].toString();
await bind.sessionSwitchSides(id: peer_id);
closeConnection(id: peer_id);
}
};
}
@@ -1289,7 +1299,9 @@ class FFI {
/// Start with the given [id]. Only transfer file if [isFileTransfer], only port forward if [isPortForward].
void start(String id,
{bool isFileTransfer = false, bool isPortForward = false}) {
{bool isFileTransfer = false,
bool isPortForward = false,
String? switchUuid}) {
assert(!(isFileTransfer && isPortForward), 'more than one connect type');
if (isFileTransfer) {
connType = ConnType.fileTransfer;
@@ -1305,7 +1317,11 @@ class FFI {
}
// ignore: unused_local_variable
final addRes = bind.sessionAddSync(
id: id, isFileTransfer: isFileTransfer, isPortForward: isPortForward);
id: id,
isFileTransfer: isFileTransfer,
isPortForward: isPortForward,
switchUuid: switchUuid ?? "",
);
final stream = bind.sessionStart(id: id);
final cb = ffiModel.startEventListener(id);
() async {

View File

@@ -601,6 +601,7 @@ class Client {
bool restart = false;
bool recording = false;
bool disconnected = false;
bool fromSwitch = false;
RxBool hasUnreadChatMessage = false.obs;
@@ -621,6 +622,7 @@ class Client {
restart = json['restart'];
recording = json['recording'];
disconnected = json['disconnected'];
fromSwitch = json['from_switch'];
}
Map<String, dynamic> toJson() {
@@ -638,6 +640,7 @@ class Client {
data['restart'] = restart;
data['recording'] = recording;
data['disconnected'] = disconnected;
data['from_switch'] = fromSwitch;
return data;
}