private int GetJavaScriptExecutionIDAndRegisterCallbacks(JavaScriptExecutionCallbacks _Callbacks) { int execID = AllocateJavaScriptExecutionID(); if (_Callbacks != null) { m_JavaScriptCallbacks.Add(execID, _Callbacks); } return(execID); }
public static void TriggerJavaScriptResultCallbackArray(System.IntPtr _WebViewInstance, int _Length, int _ExecutionID) { AwesomiumUnityWebView caller = null; JavaScriptExecutionCallbacks callbacks = FindJavaScriptCallbacksForExecutionID(_WebViewInstance, _ExecutionID, out caller); if (callbacks != null && callbacks.ArrayResult != null) { callbacks.ArrayResult(caller, _Length); } }
public static void TriggerJavaScriptResultCallbackString(System.IntPtr _WebViewInstance, string _String, int _ExecutionID) { AwesomiumUnityWebView caller = null; JavaScriptExecutionCallbacks callbacks = FindJavaScriptCallbacksForExecutionID(_WebViewInstance, _ExecutionID, out caller); if (callbacks != null && callbacks.StringResult != null) { callbacks.StringResult(caller, _String); } }
private static JavaScriptExecutionCallbacks FindJavaScriptCallbacksForExecutionID(System.IntPtr _WebViewInstance, int _ExecutionID, out AwesomiumUnityWebView _Caller) { _Caller = AwesomiumUnityWebCore.FindWebViewByNativePtr(_WebViewInstance); JavaScriptExecutionCallbacks callbacks = null; if (_Caller != null) { _Caller.m_JavaScriptCallbacks.TryGetValue(_ExecutionID, out callbacks); } return(callbacks); }
public void ExecuteJavaScript(string _Script, OnJavaScriptExecFinished _ExecFinishedCallback) { JavaScriptExecutionCallbacks callbacks = null; if (_ExecFinishedCallback != null) { callbacks = new JavaScriptExecutionCallbacks(); callbacks.ExecutionFinished += _ExecFinishedCallback; } int executionID = GetJavaScriptExecutionIDAndRegisterCallbacks(callbacks); awe_webview_executejavascript(m_Instance, _Script, executionID); }
public static void TriggerJavaScriptExecFinished(System.IntPtr _WebViewInstance, int _ExecutionID) { AwesomiumUnityWebView caller = null; JavaScriptExecutionCallbacks callbacks = FindJavaScriptCallbacksForExecutionID(_WebViewInstance, _ExecutionID, out caller); if (callbacks != null && callbacks.ExecutionFinished != null) { callbacks.ExecutionFinished(caller); // Now that execution has finished we can remove the callbacks from our dictionary. caller.m_JavaScriptCallbacks.Remove(_ExecutionID); } }
private int GetJavaScriptExecutionIDAndRegisterCallbacks(JavaScriptExecutionCallbacks _Callbacks) { int execID = AllocateJavaScriptExecutionID(); if (_Callbacks != null) { m_JavaScriptCallbacks.Add(execID, _Callbacks); } return execID; }
// Executes the javascript script _Script on the webview and calls callback(s) for the result. // If the result is an integer, the integer callback is called. If the result is a bool, the boolean callback is called (etc). // If the result is an array, the array callback is first called with the length as one of its parameters. Then, for each element in the array // the appropriate other callback is called (may recurse into another array callback). Finally, once the array iteration has finished // the array callback is called once again, this time with its length parameter being -1. public void ExecuteJavaScriptWithResult( string _Script, JavaScriptExecutionCallbacks _Callbacks ) { int executionID = GetJavaScriptExecutionIDAndRegisterCallbacks(_Callbacks); awe_webview_executejavascriptwithresult(m_Instance, _Script, executionID); }
public void ExecuteJavaScript( string _Script, OnJavaScriptExecFinished _ExecFinishedCallback ) { JavaScriptExecutionCallbacks callbacks = null; if (_ExecFinishedCallback != null) { callbacks = new JavaScriptExecutionCallbacks(); callbacks.ExecutionFinished += _ExecFinishedCallback; } int executionID = GetJavaScriptExecutionIDAndRegisterCallbacks(callbacks); awe_webview_executejavascript(m_Instance, _Script, executionID); }
// Executes the javascript script _Script on the webview and calls callback(s) for the result. // If the result is an integer, the integer callback is called. If the result is a bool, the boolean callback is called (etc). // If the result is an array, the array callback is first called with the length as one of its parameters. Then, for each element in the array // the appropriate other callback is called (may recurse into another array callback). Finally, once the array iteration has finished // the array callback is called once again, this time with its length parameter being -1. public void ExecuteJavaScriptWithResult(string _Script, JavaScriptExecutionCallbacks _Callbacks) { int executionID = GetJavaScriptExecutionIDAndRegisterCallbacks(_Callbacks); awe_webview_executejavascriptwithresult(m_Instance, _Script, executionID); }