mirror of
https://github.com/rustdesk/rustdesk.git
synced 2025-05-11 18:36:11 +02:00
refactor windows specific session (#7170)
1. Modify the process to have the control side lead the session switching: After the control side sends a `LoginRequest`, the controlled side will add all session information and the current session ID in the `LoginResponse`. Upon receiving the `LoginResponse`, the control side will check if the current session ID matches the ID in the `LoginConfigHandler`. If they match, the control side will send the current session ID. If they don't match, a session selection dialog will pop up, the selected session id will be sent. Upon receiving this message, the controlled side will restart if different or sub service if same . 2. Always show physical console session on the top 3. Show running session and distinguish sessions with the same name 4. Not sub service until correct session id is ensured 5. Fix switch sides not work for multisession session 6. Remove all session string join/split except get_available_sessions in windows.rs 7. Fix prelogin, when share rdp is enabled and there is a rdp session, the console is in login screen, get_active_username will be the rdp's username and prelogin will be false, cm can't be created an that causes disconnection in a loop 8. Rename all user session to windows session Known issue: 1. Use current process session id for `run_as_user`, sahil says it can be wrong but I didn't reproduce. 2. Have not change tray process to current session 3. File transfer doesn't update home directory when session changed 4. When it's in login screen, remote file directory is empty, because cm have not start up Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
parent
4f1a4dc6a5
commit
0f44de7dc3
18 changed files with 376 additions and 416 deletions
|
@ -1,4 +1,5 @@
|
|||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
@ -1862,6 +1863,7 @@ void enter2FaDialog(
|
|||
});
|
||||
}
|
||||
|
||||
// This dialog should not be dismissed, otherwise it will be black screen, have not reproduced this.
|
||||
void showWindowsSessionsDialog(
|
||||
String type,
|
||||
String title,
|
||||
|
@ -1870,97 +1872,40 @@ void showWindowsSessionsDialog(
|
|||
SessionID sessionId,
|
||||
String peerId,
|
||||
String sessions) {
|
||||
List<String> sessionsList = sessions.split(',');
|
||||
Map<String, String> sessionMap = {};
|
||||
for (var session in sessionsList) {
|
||||
var sessionInfo = session.split('-');
|
||||
if (sessionInfo.isNotEmpty) {
|
||||
sessionMap[sessionInfo[0]] = sessionInfo[1];
|
||||
}
|
||||
List<dynamic> sessionsList = [];
|
||||
try {
|
||||
sessionsList = json.decode(sessions);
|
||||
} catch (e) {
|
||||
print(e);
|
||||
}
|
||||
String selectedUserValue = sessionMap.keys.first;
|
||||
List<String> sids = [];
|
||||
List<String> names = [];
|
||||
for (var session in sessionsList) {
|
||||
sids.add(session['sid']);
|
||||
names.add(session['name']);
|
||||
}
|
||||
String selectedUserValue = sids.first;
|
||||
dialogManager.dismissAll();
|
||||
dialogManager.show((setState, close, context) {
|
||||
onConnect() {
|
||||
bind.sessionReconnect(
|
||||
sessionId: sessionId,
|
||||
forceRelay: false,
|
||||
userSessionId: selectedUserValue);
|
||||
dialogManager.dismissAll();
|
||||
dialogManager.showLoading(translate('Connecting...'),
|
||||
onCancel: closeConnection);
|
||||
submit() {
|
||||
bind.sessionSendSelectedSessionId(
|
||||
sessionId: sessionId, sid: selectedUserValue);
|
||||
close();
|
||||
}
|
||||
|
||||
return CustomAlertDialog(
|
||||
title: null,
|
||||
content: msgboxContent(type, title, text),
|
||||
actions: [
|
||||
SessionsDropdown(peerId, sessionId, sessionMap, (value) {
|
||||
setState(() {
|
||||
selectedUserValue = value;
|
||||
});
|
||||
}),
|
||||
dialogButton('Connect', onPressed: onConnect, isOutline: false),
|
||||
ComboBox(
|
||||
keys: sids,
|
||||
values: names,
|
||||
initialKey: selectedUserValue,
|
||||
onChanged: (value) {
|
||||
selectedUserValue = value;
|
||||
}),
|
||||
dialogButton('Connect', onPressed: submit, isOutline: false),
|
||||
],
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
class SessionsDropdown extends StatefulWidget {
|
||||
final String peerId;
|
||||
final SessionID sessionId;
|
||||
final Map<String, String> sessions;
|
||||
final Function(String) onValueChanged;
|
||||
|
||||
SessionsDropdown(
|
||||
this.peerId, this.sessionId, this.sessions, this.onValueChanged);
|
||||
|
||||
@override
|
||||
_SessionsDropdownState createState() => _SessionsDropdownState();
|
||||
}
|
||||
|
||||
class _SessionsDropdownState extends State<SessionsDropdown> {
|
||||
late String selectedValue;
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
selectedValue = widget.sessions.keys.first;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
width: 300,
|
||||
child: DropdownButton<String>(
|
||||
value: selectedValue,
|
||||
isExpanded: true,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
padding: EdgeInsets.symmetric(horizontal: 10, vertical: 5),
|
||||
items: widget.sessions.entries.map((entry) {
|
||||
return DropdownMenuItem(
|
||||
value: entry.key,
|
||||
child: Text(
|
||||
entry.value,
|
||||
style: TextStyle(
|
||||
color: MyTheme.currentThemeMode() == ThemeMode.dark
|
||||
? Colors.white
|
||||
: MyTheme.dark,
|
||||
),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
onChanged: (value) {
|
||||
if (value != null) {
|
||||
setState(() {
|
||||
selectedValue = value;
|
||||
});
|
||||
widget.onValueChanged(value);
|
||||
}
|
||||
},
|
||||
style: TextStyle(
|
||||
fontSize: 16.0,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue