mirror of
https://github.com/rustdesk/rustdesk.git
synced 2025-12-12 02:57:22 +00:00
use new event channel for mobile and web
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:typed_data';
|
||||
import 'dart:js' as js;
|
||||
import 'dart:js';
|
||||
|
||||
import '../common.dart';
|
||||
import 'dart:html';
|
||||
@@ -7,39 +8,46 @@ import 'dart:async';
|
||||
|
||||
final List<StreamSubscription<MouseEvent>> mouseListeners = [];
|
||||
final List<StreamSubscription<KeyboardEvent>> keyListeners = [];
|
||||
int lastMouseDownButtons = 0;
|
||||
bool mouseIn = false;
|
||||
|
||||
class PlatformFFI {
|
||||
static void clearRgbaFrame() {}
|
||||
|
||||
static Uint8List? getRgba() {
|
||||
return js.context.callMethod('getRgba');
|
||||
return context.callMethod('getRgba');
|
||||
}
|
||||
|
||||
static String getByName(String name, [String arg = '']) {
|
||||
return js.context.callMethod('getByName', [name, arg]);
|
||||
return context.callMethod('getByName', [name, arg]);
|
||||
}
|
||||
|
||||
static void setByName(String name, [String value = '']) {
|
||||
js.context.callMethod('setByName', [name, value]);
|
||||
context.callMethod('setByName', [name, value]);
|
||||
}
|
||||
|
||||
static Future<Null> init() async {
|
||||
isWeb = true;
|
||||
isDesktop = !js.context.callMethod('isMobile');
|
||||
js.context.callMethod('init');
|
||||
isDesktop = !context.callMethod('isMobile');
|
||||
context.callMethod('init');
|
||||
version = getByName('version');
|
||||
}
|
||||
|
||||
static void setEventCallback(void Function(Map<String, dynamic>) fun) async {
|
||||
context["onGlobalEvent"] = (String message) {
|
||||
try {
|
||||
Map<String, dynamic> event = json.decode(message);
|
||||
fun(event);
|
||||
} catch (e) {
|
||||
print('json.decode fail(): $e');
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
static void startDesktopWebListener() {
|
||||
mouseIn = true;
|
||||
mouseListeners.add(
|
||||
window.document.onContextMenu.listen((evt) => evt.preventDefault()));
|
||||
}
|
||||
|
||||
static void stopDesktopWebListener() {
|
||||
mouseIn = true;
|
||||
mouseListeners.forEach((l) {
|
||||
l.cancel();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user