NativeInterfaceJSScripting.h
1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Engine/Source/Runtime/WebBrowser/Private/Native/NativeJSScripting.h
#pragma once
#include "CoreMinimal.h"
#include "WebInterfaceJSFunction.h"
#include "WebInterfaceJSScripting.h"
typedef TSharedRef<class FNativeInterfaceJSScripting> FNativeInterfaceJSScriptingRef;
typedef TSharedPtr<class FNativeInterfaceJSScripting> FNativeInterfaceJSScriptingPtr;
class FNativeWebInterfaceBrowserProxy;
/**
* Implements handling of bridging UObjects client side with JavaScript renderer side.
*/
class FNativeInterfaceJSScripting
: public FWebInterfaceJSScripting
, public TSharedFromThis<FNativeInterfaceJSScripting>
{
public:
//static const FString JSMessageTag;
FNativeInterfaceJSScripting(bool bJSBindingToLoweringEnabled, TSharedRef<FNativeWebInterfaceBrowserProxy> Window);
virtual void BindUObject(const FString& Name, UObject* Object, bool bIsPermanent = true) override;
virtual void UnbindUObject(const FString& Name, UObject* Object = nullptr, bool bIsPermanent = true) override;
bool OnJsMessageReceived(const FString& Message);
FString ConvertStruct(UStruct* TypeInfo, const void* StructPtr);
FString ConvertObject(UObject* Object);
virtual void InvokeJSFunction(FGuid FunctionId, int32 ArgCount, FWebInterfaceJSParam Arguments[], bool bIsError=false) override;
virtual void InvokeJSErrorResult(FGuid FunctionId, const FString& Error) override;
void PageLoaded();
private:
FString GetInitializeScript();
void InvokeJSFunctionRaw(FGuid FunctionId, const FString& JSValue, bool bIsError=false);
bool IsValid()
{
return WindowPtr.Pin().IsValid();
}
/** Message handling helpers */
bool HandleExecuteUObjectMethodMessage(const TArray<FString>& Params);
void ExecuteJavascript(const FString& Javascript);
TWeakPtr<FNativeWebInterfaceBrowserProxy> WindowPtr;
bool bLoaded;
};