fix #4533
This commit is contained in:
parent
23b1e0ddec
commit
a9098960d1
@ -38,7 +38,7 @@ import 'platform_model.dart';
|
|||||||
|
|
||||||
typedef HandleMsgBox = Function(Map<String, dynamic> evt, String id);
|
typedef HandleMsgBox = Function(Map<String, dynamic> evt, String id);
|
||||||
typedef ReconnectHandle = Function(OverlayDialogManager, SessionID, bool);
|
typedef ReconnectHandle = Function(OverlayDialogManager, SessionID, bool);
|
||||||
final _waitForImage = <String, bool>{};
|
final _waitForImage = <UuidValue, bool>{};
|
||||||
|
|
||||||
class FfiModel with ChangeNotifier {
|
class FfiModel with ChangeNotifier {
|
||||||
PeerInfo _pi = PeerInfo();
|
PeerInfo _pi = PeerInfo();
|
||||||
@ -491,7 +491,7 @@ class FfiModel with ChangeNotifier {
|
|||||||
parent.target?.dialogManager.showLoading(
|
parent.target?.dialogManager.showLoading(
|
||||||
translate('Connected, waiting for image...'),
|
translate('Connected, waiting for image...'),
|
||||||
onCancel: closeConnection);
|
onCancel: closeConnection);
|
||||||
_waitForImage[peerId] = true;
|
_waitForImage[sessionId] = true;
|
||||||
_reconnects = 1;
|
_reconnects = 1;
|
||||||
}
|
}
|
||||||
Map<String, dynamic> features = json.decode(evt['features']);
|
Map<String, dynamic> features = json.decode(evt['features']);
|
||||||
@ -637,14 +637,14 @@ class ImageModel with ChangeNotifier {
|
|||||||
addCallbackOnFirstImage(Function(String) cb) => callbacksOnFirstImage.add(cb);
|
addCallbackOnFirstImage(Function(String) cb) => callbacksOnFirstImage.add(cb);
|
||||||
|
|
||||||
onRgba(Uint8List rgba) {
|
onRgba(Uint8List rgba) {
|
||||||
final waitforImage = _waitForImage[id];
|
final waitforImage = _waitForImage[sessionId];
|
||||||
if (waitforImage == null) {
|
if (waitforImage == null) {
|
||||||
debugPrint('Exception, peer $id not found for waiting image');
|
debugPrint('Exception, peer $id not found for waiting image');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (waitforImage == true) {
|
if (waitforImage == true) {
|
||||||
_waitForImage[id] = false;
|
_waitForImage[sessionId] = false;
|
||||||
parent.target?.dialogManager.dismissAll();
|
parent.target?.dialogManager.dismissAll();
|
||||||
if (isDesktop) {
|
if (isDesktop) {
|
||||||
for (final cb in callbacksOnFirstImage) {
|
for (final cb in callbacksOnFirstImage) {
|
||||||
@ -1584,6 +1584,7 @@ class FFI {
|
|||||||
var id = '';
|
var id = '';
|
||||||
var version = '';
|
var version = '';
|
||||||
var connType = ConnType.defaultConn;
|
var connType = ConnType.defaultConn;
|
||||||
|
var closed = false;
|
||||||
|
|
||||||
/// dialogManager use late to ensure init after main page binding [globalKey]
|
/// dialogManager use late to ensure init after main page binding [globalKey]
|
||||||
late final dialogManager = OverlayDialogManager();
|
late final dialogManager = OverlayDialogManager();
|
||||||
@ -1655,13 +1656,16 @@ class FFI {
|
|||||||
);
|
);
|
||||||
final stream = bind.sessionStart(sessionId: sessionId, id: id);
|
final stream = bind.sessionStart(sessionId: sessionId, id: id);
|
||||||
final cb = ffiModel.startEventListener(sessionId, id);
|
final cb = ffiModel.startEventListener(sessionId, id);
|
||||||
() async {
|
final useTextureRender = bind.mainUseTextureRender();
|
||||||
final useTextureRender = bind.mainUseTextureRender();
|
// Preserved for the rgba data.
|
||||||
// Preserved for the rgba data.
|
stream.listen((message) {
|
||||||
await for (final message in stream) {
|
if (closed) return;
|
||||||
|
() async {
|
||||||
if (message is EventToUI_Event) {
|
if (message is EventToUI_Event) {
|
||||||
if (message.field0 == "close") {
|
if (message.field0 == "close") {
|
||||||
break;
|
closed = true;
|
||||||
|
debugPrint('Exit session event loop');
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, dynamic>? event;
|
Map<String, dynamic>? event;
|
||||||
@ -1675,8 +1679,8 @@ class FFI {
|
|||||||
}
|
}
|
||||||
} else if (message is EventToUI_Rgba) {
|
} else if (message is EventToUI_Rgba) {
|
||||||
if (useTextureRender) {
|
if (useTextureRender) {
|
||||||
if (_waitForImage[id]!) {
|
if (_waitForImage[sessionId]!) {
|
||||||
_waitForImage[id] = false;
|
_waitForImage[sessionId] = false;
|
||||||
dialogManager.dismissAll();
|
dialogManager.dismissAll();
|
||||||
for (final cb in imageModel.callbacksOnFirstImage) {
|
for (final cb in imageModel.callbacksOnFirstImage) {
|
||||||
cb(id);
|
cb(id);
|
||||||
@ -1696,9 +1700,8 @@ class FFI {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}();
|
||||||
debugPrint('Exit session event loop');
|
});
|
||||||
}();
|
|
||||||
// every instance will bind a stream
|
// every instance will bind a stream
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
@ -1716,6 +1719,7 @@ class FFI {
|
|||||||
|
|
||||||
/// Close the remote session.
|
/// Close the remote session.
|
||||||
Future<void> close() async {
|
Future<void> close() async {
|
||||||
|
closed = true;
|
||||||
chatModel.close();
|
chatModel.close();
|
||||||
if (imageModel.image != null && !isWebDesktop) {
|
if (imageModel.image != null && !isWebDesktop) {
|
||||||
await setCanvasConfig(
|
await setCanvasConfig(
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:ffi';
|
import 'dart:ffi';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'dart:typed_data';
|
|
||||||
|
|
||||||
import 'package:device_info_plus/device_info_plus.dart';
|
import 'package:device_info_plus/device_info_plus.dart';
|
||||||
import 'package:external_path/external_path.dart';
|
import 'package:external_path/external_path.dart';
|
||||||
@ -9,10 +8,8 @@ import 'package:ffi/ffi.dart';
|
|||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_hbb/consts.dart';
|
import 'package:flutter_hbb/consts.dart';
|
||||||
import 'package:get/get.dart';
|
|
||||||
import 'package:package_info_plus/package_info_plus.dart';
|
import 'package:package_info_plus/package_info_plus.dart';
|
||||||
import 'package:path_provider/path_provider.dart';
|
import 'package:path_provider/path_provider.dart';
|
||||||
import 'package:win32/win32.dart' as win32;
|
|
||||||
|
|
||||||
import '../common.dart';
|
import '../common.dart';
|
||||||
import '../generated_bridge.dart';
|
import '../generated_bridge.dart';
|
||||||
@ -266,9 +263,9 @@ class PlatformFFI {
|
|||||||
|
|
||||||
/// Start listening to the Rust core's events and frames.
|
/// Start listening to the Rust core's events and frames.
|
||||||
void _startListenEvent(RustdeskImpl rustdeskImpl) {
|
void _startListenEvent(RustdeskImpl rustdeskImpl) {
|
||||||
() async {
|
var sink = rustdeskImpl.startGlobalEventStream(appType: _appType);
|
||||||
await for (final message
|
sink.listen((message) {
|
||||||
in rustdeskImpl.startGlobalEventStream(appType: _appType)) {
|
() async {
|
||||||
try {
|
try {
|
||||||
Map<String, dynamic> event = json.decode(message);
|
Map<String, dynamic> event = json.decode(message);
|
||||||
// _tryHandle here may be more flexible than _eventCallback
|
// _tryHandle here may be more flexible than _eventCallback
|
||||||
@ -280,8 +277,8 @@ class PlatformFFI {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
debugPrint('json.decode fail(): $e');
|
debugPrint('json.decode fail(): $e');
|
||||||
}
|
}
|
||||||
}
|
}();
|
||||||
}();
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void setEventCallback(StreamEventHandler fun) async {
|
void setEventCallback(StreamEventHandler fun) async {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user