This commit is contained in:
rustdesk
2023-06-09 11:32:36 +08:00
parent 23b1e0ddec
commit a9098960d1
2 changed files with 23 additions and 22 deletions

View File

@@ -1,7 +1,6 @@
import 'dart:convert';
import 'dart:ffi';
import 'dart:io';
import 'dart:typed_data';
import 'package:device_info_plus/device_info_plus.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/services.dart';
import 'package:flutter_hbb/consts.dart';
import 'package:get/get.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:path_provider/path_provider.dart';
import 'package:win32/win32.dart' as win32;
import '../common.dart';
import '../generated_bridge.dart';
@@ -266,9 +263,9 @@ class PlatformFFI {
/// Start listening to the Rust core's events and frames.
void _startListenEvent(RustdeskImpl rustdeskImpl) {
() async {
await for (final message
in rustdeskImpl.startGlobalEventStream(appType: _appType)) {
var sink = rustdeskImpl.startGlobalEventStream(appType: _appType);
sink.listen((message) {
() async {
try {
Map<String, dynamic> event = json.decode(message);
// _tryHandle here may be more flexible than _eventCallback
@@ -280,8 +277,8 @@ class PlatformFFI {
} catch (e) {
debugPrint('json.decode fail(): $e');
}
}
}();
}();
});
}
void setEventCallback(StreamEventHandler fun) async {