multi remote instances

This commit is contained in:
csf
2022-05-31 14:44:06 +08:00
parent 00ba7cad81
commit 18ad23435b
5 changed files with 182 additions and 194 deletions

View File

@@ -404,7 +404,7 @@ class _RemotePageState extends State<RemotePage> with WindowListener {
icon: Icon(Icons.tv),
onPressed: () {
setState(() => _showEdit = false);
showOptions();
showOptions(widget.id);
},
)
] +
@@ -972,8 +972,9 @@ RadioListTile<String> getRadio(String name, String toValue, String curValue,
);
}
void showOptions() {
String quality = FFI.getByName('image_quality');
void showOptions(String id) async {
// String quality = FFI.getByName('image_quality');
String quality = await FFI.rustdeskImpl.getImageQuality(id: id) ?? 'balanced';
if (quality == '') quality = 'balanced';
String viewStyle = FFI.getByName('peer_option', 'view-style');
var displays = <Widget>[];

View File

@@ -6,6 +6,7 @@ import 'dart:ui' as ui;
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_hbb/generated_bridge.dart';
import 'package:flutter_hbb/models/chat_model.dart';
import 'package:flutter_hbb/models/file_model.dart';
import 'package:flutter_hbb/models/server_model.dart';
@@ -598,17 +599,17 @@ class CursorModel with ChangeNotifier {
final rgba = Uint8List.fromList(colors.map((s) => s as int).toList());
var pid = FFI.id;
ui.decodeImageFromPixels(rgba, width, height, ui.PixelFormat.rgba8888,
(image) {
if (FFI.id != pid) return;
_image = image;
_images[id] = Tuple3(image, _hotx, _hoty);
try {
// my throw exception, because the listener maybe already dispose
notifyListeners();
} catch (e) {
print('notify cursor: $e');
}
});
(image) {
if (FFI.id != pid) return;
_image = image;
_images[id] = Tuple3(image, _hotx, _hoty);
try {
// my throw exception, because the listener maybe already dispose
notifyListeners();
} catch (e) {
print('notify cursor: $e');
}
});
}
void updateCursorId(Map<String, dynamic> evt) {
@@ -637,7 +638,8 @@ class CursorModel with ChangeNotifier {
notifyListeners();
}
void updateDisplayOriginWithCursor(double x, double y, double xCursor, double yCursor) {
void updateDisplayOriginWithCursor(
double x, double y, double xCursor, double yCursor) {
_displayOriginX = x;
_displayOriginY = y;
_x = xCursor;
@@ -765,7 +767,7 @@ class FFI {
return peers
.map((s) => s as List<dynamic>)
.map((s) =>
Peer.fromJson(s[0] as String, s[1] as Map<String, dynamic>))
Peer.fromJson(s[0] as String, s[1] as Map<String, dynamic>))
.toList();
} catch (e) {
print('peers(): $e');
@@ -779,7 +781,11 @@ class FFI {
setByName('connect_file_transfer', id);
} else {
FFI.chatModel.resetClientMode();
setByName('connect', id);
// setByName('connect', id);
final stream =
FFI.rustdeskImpl.connect(id: id, isFileTransfer: isFileTransfer);
// listen stream ...
// every instance will bind a stream
}
FFI.id = id;
}
@@ -833,6 +839,8 @@ class FFI {
PlatformFFI.setByName(name, value);
}
static RustdeskImpl get rustdeskImpl => PlatformFFI.rustdeskImpl;
static handleMouse(Map<String, dynamic> evt) {
var type = '';
var isMove = false;

View File

@@ -30,9 +30,12 @@ class PlatformFFI {
static String _homeDir = '';
static F2? _getByName;
static F3? _setByName;
static late RustdeskImpl _rustdeskImpl;
static void Function(Map<String, dynamic>)? _eventCallback;
static void Function(Uint8List)? _rgbaCallback;
static RustdeskImpl get rustdeskImpl => _rustdeskImpl;
static Future<String> getVersion() async {
PackageInfo packageInfo = await PackageInfo.fromPlatform();
return packageInfo.version;
@@ -88,7 +91,8 @@ class PlatformFFI {
dylib.lookupFunction<Void Function(Pointer<Utf8>, Pointer<Utf8>), F3>(
'set_by_name');
_dir = (await getApplicationDocumentsDirectory()).path;
_startListenEvent(RustdeskImpl(dylib));
_rustdeskImpl = RustdeskImpl(dylib);
_startListenEvent(_rustdeskImpl); // global event
try {
_homeDir = (await ExternalPath.getExternalStorageDirectories())[0];
} catch (e) {