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); } } } } }
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); } }
private async void Webview_WebMessageReceived(object?sender, CoreWebView2WebMessageReceivedEventArgs e) { await bridge.HandleScriptCall(e.TryGetWebMessageAsString()); }
/// <summary> /// Script invoke hook. /// </summary> /// <param name="data">The sent data.</param> public async void notify(string data) { await bridge.HandleScriptCall(data); }
private async void Webview_WebMessageReceived(object sender, CoreWebView2WebMessageReceivedEventArgs e) { await bridge.HandleScriptCall(e.WebMessageAsJson); }
private async void Webview_ScriptNotify(IWebViewControl sender, WebViewControlScriptNotifyEventArgs e) { await bridge.HandleScriptCall(e.Value); }