-
Notifications
You must be signed in to change notification settings - Fork 2
Generic Message Routing
Applies Only to CefGlue apps
This is info about registering handlers for Cef Generic Message Router
Cef/CefGlue IPC provides a generic implementation for routing asynchronous messages between Javascript running in the renderer process and .NET C# running in the browser process. These implementations are done internally by registering Javascript functions on the current window browser. These functions are cefQuery and cefQueryCancel.
The generic message router functions in UI are in the following formats:
// Create and send a new query.
var request_id = window.cefQuery({
request: 'my_request',
persistent: false,
onSuccess: function(response) {},
onFailure: function(error_code, error_message) {}
});
// Optionally cancel the query.
window.cefQueryCancel(request_id)
For Chromely CefGlue message routing, the following must be done:
- Use default message router handler or register a new one.
- Add appropriate cefQuery Javascript function in the UI.
To use the default handler nothing needs to be done. To register a new handler please check Configuration.
Chromely default message route handling only implements cefQuery. To implement cefQueryCancel a new handler must be implemented and registered.
The default handler expects the request to be in the following format:
var request = {
"method": method,
"url": url
"parameters": parameters,
"postData": postData,
};
Where:
method: Restful methods "GET" or "POST". Only "Get" and "POST" are allowed.
url: route path - "controller/action".
parameters: Dictionary of parameters, where keys are in string, and values can be any primitive object.
postData: Posted/input data object.
A sample CefQuery GET request in the UI will be:
function messageRouterResult(response) {
var jsonData = JSON.parse(response);
if (jsonData.ReadyState == 4 && jsonData.Status == 200) {
.... process response
}
}
function messageRouterRun() {
var request = {
"method": "GET",
"url": "/democontroller/movies",
"parameters": null,
"postData": null,
};
window.cefQuery({
request: JSON.stringify(request),
onSuccess: function (response) {
messageRouterResult(response);
}, onFailure: function (err, msg) {
console.log(err, msg);
}
});
}
Where:
On success callback function: messageRouterResult
Chromely
Getting Started
The Basics
Digging Deeper
- Sub-Process
- Infrastructure
- Restful Resources
- Register Resource Assemblies
- Custom Local Resource Handling
- Custom Scheme Handling
- Expose .NET class to JavaScript
- Generic Message Routing
- Real-time with Websocket
- External Url Registration
Angular - React - Vue