android-components / mozilla.components.concept.engine.webextension / MessageHandler

MessageHandler

interface MessageHandler (source)

A handler for all messaging related events, usable for both content and background scripts.

Ports are exposed to consumers (higher level components) because how ports are used, how many there are and how messages map to it is feature-specific and depends on the design of the web extension. Therefore it makes most sense to let the extensions (higher-level features) deal with the management of ports.

Functions

Name Summary
onMessage open fun onMessage(message: Any, source: EngineSession?): Any?
Invoked when a message was received as a result of a browser.runtime.sendNativeMessage call in JavaScript.
onPortConnected open fun onPortConnected(port: Port): Unit
Invoked when a Port was connected as a result of a browser.runtime.connectNative call in JavaScript.
onPortDisconnected open fun onPortDisconnected(port: Port): Unit
Invoked when a Port was disconnected or the corresponding session was destroyed.
onPortMessage open fun onPortMessage(message: Any, port: Port): Unit
Invoked when a message was received on the provided port.