Architecture
Last updated
Last updated
Wisej.NET Hybrid applications are built with two components: a client-side .NET MAUI application and a corresponding server application.
Depending on the Hybrid mode selected, the server layer may be located either on the device using EmbedIO as an embedded web server or deployed as a remote ASP.NET / ASP.NET Core web application to Azure or AWS.
The application layer is the part of the application that developers interact with. Developers can build user interfaces, implement business logic, and interact with the client device using the Device static class.
The application layer is built on top of Wisej.NET. Wisej.NET is a collection of tools and integrations for building complex web-based user-interfaces.
Wisej.NET is able to post and receive messages directly to the client browser using WebSocket and JavaScript to perform real-time browser updates and interact with the Hybrid Client device's embedded web browser.
The embedded WebView used in Wisej.NET Hybrid applications registers a JavaScript bridge to post and receive messages in native code.
The WebView implementation for each platform:
Android: WebView
iOS / Mac: WKWebView
Windows: WebView2
When the Hybrid Client application starts up, it builds an internal collection of request handlers that can be used to process requests. Request handlers can be dynamically added at any point in time.
Once a message is received from the embedded WebView, the request is delegated to the specific handler for processing.
All Device integrations have a corresponding client-side request handler that processes requests from the server. The handler may perform an action with or without a result to return to the server. It may also begin firing periodic events to the server, as is the case for receiving accelerometer updates.
In the example above, the request from Device.Flashlight.TurnOn() in the application layer is delegated to the corresponding client-side Flashlight handler.
Each request that comes in through the embedded WebView is delegated to a specific platform handler.
In the flashlight example above, the requests are delegated as follows:
API level 23 and higher
On newer API levels, Torch Mode will be used to turn on or off the flash unit of the device.
API level 22 and lower
A camera surface texture is created to turn on or off the FlashMode
of the camera unit.
The AVCaptureDevice
API is used to turn on and off the Torch and Flash mode of the device.
The Lamp API is used to turn on or off the first detected lamp on the back of the device.
Wisej.NET Hybrid Local applications can run entirely on the device without any need for an internet connection. The Server component in the diagram below uses an embedded web server to host the Wisej.NET application.
Wisej.NET Hybrid remote applications can be used to interact with device features while running the application on a remote web server. The Hybrid Client can configure the startup URL to point to this endpoint.