WebMessagePortCompat.WebMessageCallbackCompat

abstract class WebMessagePortCompat.WebMessageCallbackCompat


The listener for handling MessagePort events. The message callback methods are called on the main thread. If the embedder application wants to receive the messages on a different thread, it can do this by passing a Handler in setWebMessageCallback. In the latter case, the application should be extra careful for thread safety since WebMessagePort methods should be called on main thread.

Summary

Public constructors

Public functions

Unit

Message callback for receiving onMessage events.

Public constructors

WebMessageCallbackCompat

Added in 1.1.0
WebMessageCallbackCompat()

Public functions

onMessage

Added in 1.1.0
fun onMessage(port: WebMessagePortCompat, message: WebMessageCompat?): Unit

Message callback for receiving onMessage events.

This method is called only if WEB_MESSAGE_CALLBACK_ON_MESSAGE is supported. You can check whether that flag is supported using isFeatureSupported.

Parameters
port: WebMessagePortCompat

the WebMessagePort that the message is destined for

message: WebMessageCompat?

the message from the entangled port.