Custom Handler

If functionality is needed that isn't included in the built-in modules or extensions, the hybrid integration can be extended to provide custom modules with properties, methods, and events.

circle-info

Contact [email protected]envelope to get a quote for custom integrations.

Handlers

Handlers are used to link the server-side and client-side (MAUI) integrations. Handlers implement the IClientHandler interface and provide several methods for processing requests from a Wisej.NET application which can be used to wire custom properties, methods, and events.

Example Client-Side Handler Integration

/// <summary>
/// Client-side integration for mathematical operations.
/// </summary>
internal class MathHandler : IClientHandler
{
	string IClientHandler.Identifier => "math";

	bool IClientHandler.ProcessRequest(DeviceRequest request)
	{
		var num1 = request.Arguments[0];
		var num2 = request.Arguments[1];
	
		switch (request.Action)
		{
			case "add":
				App.FireModalResponse(Add(num1, num2));
				return true;

			case "subtract":
				App.FireModalResponse(Subtract(num1, num2));
				return true;

			default:
				return false;
		}
	}

	void IClientHandler.Reset()
	{
		// reset the UI changes.
	}

	private DeviceResponse Add(int num1, int num2)
	{
		return new DeviceResponse(num1 + num2);			
	}

	private DeviceResponse Subtract(int num1, int num2) 
	{
		return new DeviceResponse(num1 - num2);			
	}
}

Registering Client-Side Handler

Example Usage on Server

Firing Native Events to the Server

If you only need to push data from the native MAUI app to the Wisej.NET server, you don't need to build a full custom request/response handler.

Use Wisej.Hybrid.Native.App.FireEvent(...) on the native side and handle the event on the server using Device.RegisterEventListener(...).

This is useful for scenarios such as:

  • barcode or RFID scans received through Android intents

  • native lifecycle notifications

  • custom data coming from platform-specific code

Example Client-Side Event

You can also use the convenience overload when the default application handler is enough:

Example Usage on Server

circle-info

Use a custom IClientHandler when the server needs to invoke native actions or request a response. Use App.FireEvent(...) when the native side only needs to publish an event back to the server.

Information Providers

Information providers are used to extend the Device.Info member. They provide information on startup about the client hybrid device and its capabilities. New information providers can be registered by adding a new IClientInfoProvider.

Example Client-Side Information Provider

Example Implementation on Server

Example Usage on Server

Last updated