Inter-process messaging in the CEF3 developer series

Source: Internet
Author: User

When using CEF3 as a framework development process, WebSockets, XMLHttpRequest, JS, and local client interactions are required to deliver messages in the render process and in the browse (Browser) session. CEF3 is well encapsulated in this area, and the average user can implement interprocess messaging with only a few interfaces and functions to understand. According to the personal development experience and understanding, take cefclient as an example to summarize the CEF3 message transmission mechanism, there is not correct, please enlighten!

The Cefbrowser::sendprocessmessage () method is typically called through the specified Cefbrowser instance. Because the cefbrowser and cefframe objects exist in both the browser and render processes, both the render process and the browse (browser) process can be called to the Sendprocessmessage () method. Sendprocessmessage () has two parameters, the process identifies the CEFPROCESSID with the message that needs to be passed cefprocessmessage.

Cefprocessid is an enumeration constant, and the meaning of the specific representation is not explained, see the code shown below:

typedef enum {  ///  //Browser process.  Pid_browser,////  Renderer process.  Pid_renderer,} cef_process_id_t;

Cefprocessmessage is a class that manages the delivery of messages, including the message name and message content. See the code example below:

Cefrefptr<cefprocessmessage> message = Cefprocessmessage::create (cefstring ("Xiaoximingcheng"));  Set message name cefrefptr<ceflistvalue> args = Message->getargumentlist (); Cefstring  Message_cont;  Args->setstring (0, Message_cont);  Set message content

Messages are passed between processes, and are set by Getargumentlist and SetString. All render processes provide access to the same message passing through the browser process

Cefbrowserprocesshandler::onrenderprocessthreadcreated () passing messages to cefrenderprocesshandler::o in the render process Nrenderthreadcreated ().

messages sent from the browser process to The render process are received by cefrenderprocesshandler::onprocessmessagereceived (), messages sent from the render process to the browser process are received by the cefbrowserprocesshandler::onprocessmessagereceived (). See:

before the process of sending a message is received via the associated message and frame ID(via Cefframe::getidentifier ()), the receiving message process is Cefbrowser::getframe () gets frame-related information so that the frame and message correspond so that each frame can handle its own messages.

Inter-process messaging in the CEF3 developer series

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.