-
Notifications
You must be signed in to change notification settings - Fork 279
Command Routes
Commands are fire-and-forget JavaScript requests that are sent from the Renderer and processed by the Browser. As you might already have guessed, no response is returned to the Renderer.
A command must be registered and requires a URL scheme registarion and a related action method.
The configuration of an IPC workflow involves:
- Create a Controller class
- Register an Command method in the Controller class*
- Register the Controller class
- Register a scheme (http, custom, etc)*
- Create a JavaScript request in the Renderer html*
[*] We are only covering these parts of the workflow, to get the full picture please look at the Networking Introduction
Command methods can be added to Controller class in 2 ways.
- Constructor type
public DemoController()
{
RegisterCommand("/democontroller/exitprogram", ShowDevTools);
}
public void ExitProgram()
{
}
- Attribute decorated type
[Command(Route = "/democontroller/exitprogram")]
public void ExitProgram()
{
}
You can register a command scheme either in config file or via C# code.
- Using config file
"urlSchemes": [
{
"name": "default-command-http",
"baseUrl": "",
"scheme": "http",
"host": "command.com",
"urlSchemeType": "command",
"baseUrlStrict": false
}
]
- Using C# code
public class DefaultConfiguration : IChromelyConfiguration
{
public DefaultConfiguration()
{
UrlSchemes.AddRange(new List<UrlScheme>()
{
new UrlScheme("default-command-http", "http", "command.com", string.Empty, UrlSchemeType.Command, false),
});
}
}
For more info on registering a custom scheme please see Custom Http Registration.
To trigger an actual request, an event must must be set up in the HTML file.
A sample:
<a href="http://command.com/democontroller/exitprogram">Close App</a>
Chromely
Getting Started
Networking
Resources
Debugging
Detailed documentation on:
- Getting Started
- Configuring Chromely
- Loading Html
- Resource Handling
- Configuring Message Routing
- Register Ajax/XHR Handlers
- JavaScript Execution
- Scheme Registration
- Scheme Handlers
- Custom Http Handlers
- How to use commands
- Custom CEF Handlers
- Chromely on Raspberry Pi
- How to use app settings
- CEF binaries download
- Using DevTools