Esempio n. 1
0
        private async void ScriptCallback(IntPtr manager, IntPtr jsResult, IntPtr userdata)
        {
            if (EnableScriptInterface)
            {
                IntPtr value = WebKit.JavaScript.GetValue(jsResult);
                if (WebKit.JavaScript.IsValueString(value))
                {
                    IntPtr bytes = IntPtr.Zero;
                    try
                    {
                        bytes = WebKit.JavaScript.GetStringBytes(value);
                        IntPtr bytesPtr = GLib.GetBytesDataPointer(bytes, out UIntPtr length);

                        string result;
                        unsafe { result = Encoding.UTF8.GetString((byte *)bytesPtr, (int)length); }

                        await bridge.HandleScriptCall(result);
                    }
                    finally { if (bytes != IntPtr.Zero)
                              {
                                  GLib.UnrefBytes(bytes);
                              }
                    }
                }
            }
        }
Esempio n. 2
0
        private async void ScriptCallback(IntPtr self, IntPtr op, IntPtr notification, IntPtr message)
        {
            IntPtr body     = ObjC.Call(message, "body");
            IntPtr isString = ObjC.Call(body, "isKindOfClass:", Foundation.GetClass("NSString"));

            if (isString != IntPtr.Zero)
            {
                string data = NSString.GetString(body);
                await bridge.HandleScriptCall(data);
            }
        }
Esempio n. 3
0
 private async void Webview_WebMessageReceived(object?sender, CoreWebView2WebMessageReceivedEventArgs e)
 {
     await bridge.HandleScriptCall(e.TryGetWebMessageAsString());
 }
Esempio n. 4
0
 /// <summary>
 /// Script invoke hook.
 /// </summary>
 /// <param name="data">The sent data.</param>
 public async void notify(string data)
 {
     await bridge.HandleScriptCall(data);
 }
Esempio n. 5
0
 private async void Webview_WebMessageReceived(object sender, CoreWebView2WebMessageReceivedEventArgs e)
 {
     await bridge.HandleScriptCall(e.WebMessageAsJson);
 }
Esempio n. 6
0
 private async void Webview_ScriptNotify(IWebViewControl sender, WebViewControlScriptNotifyEventArgs e)
 {
     await bridge.HandleScriptCall(e.Value);
 }