WebMessagePortCompat.WebMessageCallbackCompat

public 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 methods

void

Message callback for receiving onMessage events.

Public constructors

WebMessageCallbackCompat

Added in 1.1.0
public WebMessageCallbackCompat()

Public methods

onMessage

Added in 1.1.0
public void onMessage(
    @NonNull WebMessagePortCompat port,
    @Nullable WebMessageCompat message
)

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
@NonNull WebMessagePortCompat port

the WebMessagePort that the message is destined for

@Nullable WebMessageCompat message

the message from the entangled port.