Няма описание

12345678910111213141516171819202122232425262728293031
  1. #include "pch.h"
  2. #include "WebBridge.h"
  3. using namespace WebViewBridge;
  4. using namespace Platform;
  5. using namespace Windows::UI::Core;
  6. // https://docs.microsoft.com/en-us/windows/uwp/winrt-components/create-a-windows-runtime-component-in-cppwinrt
  7. // https://github.com/microsoft/react-native-windows/blob/0.59-legacy/current/ReactWindows/ReactNativeWebViewBridge/WebViewBridge.cs
  8. // https://github.com/MicrosoftEdge/JSBrowser/blob/master/NativeListener
  9. WebBridge::WebBridge(int64 tag)
  10. {
  11. m_tag = tag;
  12. // Must run on App UI thread
  13. m_dispatcher = Windows::UI::Core::CoreWindow::GetForCurrentThread()->Dispatcher;
  14. }
  15. void WebBridge::PostMessage(int message) {
  16. m_dispatcher->RunAsync(
  17. CoreDispatcherPriority::Normal,
  18. ref new DispatchedHandler([this, message]
  19. {
  20. OutputDebugStringW(L"> WebBridge sending MessagePostedEvent");
  21. MessagePostedEvent(message);
  22. }));
  23. }