OutSystems / CefGlue

.NET binding for The Chromium Embedded Framework (CEF)
MIT License
277 stars 41 forks source link

Binary inter process communication (IPC) #164

Closed piotrek1668 closed 1 month ago

piotrek1668 commented 2 months ago

I want to send and receive binary messages using CefGlue like this:

use var message = CefProcessMessage.Create("MyBinaryMessage");
var value = CefBinaryValue.Create(new byte[] { 0, 0, 0, 1 });
message.Arguments.SetBinary(0, value);

browser.GetMainFrame().SendProcessMessage(CefProcessId.Renderer, message);

However, I cannot currently send the message because I do not have access to the MainFrame. The browser apparently encapsulates some functions.

Is this not intended in CefGlue, or am I doing something wrong here?

joaompneves commented 2 months ago

You're trying to use Cef low-level communication artillery, which is not exposed in CefGlue and neither recommended.

To pass binary to the browser I would recommend using:

piotrek1668 commented 1 month ago

@joaompneves Thanks, for your tips and suggestions.

Together with my colleagues we want to introduce an alternative binary serializer for the CefGlue library. The serializer can optionally be changed for communication between client and browser. By default, the serializer is still set to Json, but if there is a need to use a faster binary serialisiert, the user can change to use MessagePack for serialization. If large amounts of data has to be transferred, the serializer can be set to MsgPack. Depending on the data size, the transmission performance increases by a factor of 10+.

If you are interested, we have prepared a branch with this changes and some unit tests. Currently I am not able to push a branch to your repo, so please let me know if you are interested.

joaompneves commented 1 month ago

Hi,

You cannot push a branch but you can create a fork and open a PR. I can then take a look and evaluate. Thanks