Comlink C# #3327
Replies: 12 comments 13 replies
-
The ConvertMessageTo is used to create a By string are you meaning getting the data as
Can you be more specific? Send it to where exactly? Call a javascript function? Fire a javascript event?
In the context of your project what exactly are you calling a I'm never actually used |
Beta Was this translation helpful? Give feedback.
-
Again, thanks in advance for your time and effort!!! |
Beta Was this translation helpful? Give feedback.
-
Simply casting the Message property to a string should be sufficient if the message is already JSON. http://cefsharp.github.io/api/85.3.x/html/P_CefSharp_JavascriptMessageReceivedEventArgs_Message.htm
Calling a function would likely be the simplest solution, if you wish to setup an event then you'd need some JavaScript like https://developer.mozilla.org/en-US/docs/Web/API/EventTarget#Example Fundamentally you'd use ExecuteScriptAsync or EvaluateScriptAsync to call your function or dispatch your event.
I'm aware of what transferable means in the context of webworker PostMessage. If commlink c# had documentation what would it define a transferable as?
Say you pass an arraybuffer to commlink, what type does that map to in .Net? Are you creating a custom type? You are crossing a process boundary, so the data will need to be sent between processes. |
Beta Was this translation helpful? Give feedback.
-
Ok, thanks!
Ok, I'll look into this, I was hoping I could achieve this without having to inject JS, but no biggie at all. Do you racon overriding the window.parent would be a good idea? Because that would be the
Exactly the same as the
Honestly no clue, I'd say whatever type is defined in C#, as an arraybuffer (ar any transferable for that matter) is just a block of memory. so the whole point of them is to "only" transfer onwership and don't do any serialization. But I wonder if this would even be feasible for cefsharp to implement (would it even be possible for cefsharp, or would this need to be escalated to cef?). A quick somewhat off-topic side-thought, Would you recon that implementing flatbuffers be possible assuming the above mentioned transferables work? |
Beta Was this translation helpful? Give feedback.
-
Whilst the method might be called the same as that's the convention the
Perhaps you can use CefV8Value::CreateArrayBuffer in conjunction with a shared section of memory. Not something I've tried. You can ask on https://magpcss.org/ceforum/index.php and see if anyone else has attempted something similar in the context of If we look at other types like MesagePort, how does that behave you if you were to
Not sure. |
Beta Was this translation helpful? Give feedback.
-
I had my suspicions this would be the case, but non the less the same question. Do you think it is feasible to add this to cef&cefsharp. Or would this add to many edgecases and/or security risks?
I'll look into this, thanks!
in terms of JS between a page and a worker, it would be as if the I hope I'm not bothering you with these strange use-cases, thanks for your input thus far :D |
Beta Was this translation helpful? Give feedback.
-
Maybe for The other
It's an interesting idea 😄 |
Beta Was this translation helpful? Give feedback.
-
well, maybe we could take a less literal aproach here; I mean, it wouldn't as fast as just moving around a pointer, but transferring binary data seems at the least possible to me. Or am I thinking way to naïve here? |
Beta Was this translation helpful? Give feedback.
-
Yes you can copy the data. Do you have a real world application for |
Beta Was this translation helpful? Give feedback.
-
Sorry for the late reaction. I don't have an example, that's what makes this whole thing hard for me as well. Or at least, Comlink internally sets up |
Beta Was this translation helpful? Give feedback.
-
Moving conversation to new discussions section, maybe a little bit of noise. |
Beta Was this translation helpful? Give feedback.
-
I'm new here(in general), maybe this is related(sorry if not), but what is the most efficient way to transmit data from C# to JavaScript? In my use case, I use c# to capture system audio(WASAPI loopback) and calculate FastFourierTransform data then send to browser js(60 fps) to draw visualizer. I know there is ExecuteScriptAsync(data) and JavaScript Binding, and they are all IPC underneath, but in my testing both use huge amount of CPU(~10% on 4 core i7-4900mq) just sending a size 2048 array of float 60 times a second(no fft involved, sending a prepared array). Is it because they not designed to stream data and have other construct that adds overhead? Is there a more appropriate way to send the data? Or maybe I should just use webrtc to send the captured audio stream to browser? Because the only reason to do it in C# is it can capture system audio. |
Beta Was this translation helpful? Give feedback.
-
Hi @amaitland,
I saw you starred my project thanks!
I hope you don't mind me asking for a bit of help here.
I have a few issues with trying to implement the sending / receiving of messages.
currently this is my implementation
As you can see, I have 2 TODO's in here, and for both I'm unsure on how to solve them. Because if I cast the message to a String, do I get the unparsed message sent by the page? And how would I go about sending a string to the page.
And can I support transferable object as the
postMessage
specs say in any way?Thanks in advance :D
Beta Was this translation helpful? Give feedback.
All reactions