|
@@ -6,15 +6,27 @@
|
6
|
6
|
using namespace WebViewBridge;
|
7
|
7
|
using namespace Platform;
|
8
|
8
|
|
|
9
|
+using namespace Windows::UI::Core;
|
9
|
10
|
|
10
|
11
|
// https://docs.microsoft.com/en-us/windows/uwp/winrt-components/create-a-windows-runtime-component-in-cppwinrt
|
11
|
12
|
// https://github.com/microsoft/react-native-windows/blob/0.59-legacy/current/ReactWindows/ReactNativeWebViewBridge/WebViewBridge.cs
|
12
|
|
-
|
|
13
|
+// https://github.com/MicrosoftEdge/JSBrowser/blob/master/NativeListener
|
13
|
14
|
|
14
|
15
|
WebBridge::WebBridge(int64 tag)
|
15
|
16
|
{
|
16
|
|
- //winrt::hstring w{ L"Hello, World!" };
|
|
17
|
+ m_tag = tag;
|
|
18
|
+ // Must run on App UI thread
|
|
19
|
+ m_dispatcher = Windows::UI::Core::CoreWindow::GetForCurrentThread()->Dispatcher;
|
17
|
20
|
}
|
18
|
21
|
|
19
|
|
-void WebBridge::PostMessage() {
|
|
22
|
+void WebBridge::PostMessage(int message) {
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+ m_dispatcher->RunAsync(
|
|
26
|
+ CoreDispatcherPriority::Normal,
|
|
27
|
+ ref new DispatchedHandler([this, message]
|
|
28
|
+ {
|
|
29
|
+ MessagePostedEvent(message);
|
|
30
|
+ }));
|
|
31
|
+
|
20
|
32
|
}
|