Skip to content

DataChannelEventListener

Lejla Solak edited this page Oct 26, 2023 · 1 revision



onTextDelivered(textDeliveredEvent)

Description

Method that is triggered when the previously sent text has been (un)successfully delivered.

Arguments

  • textDeliveredEvent: TextDeliveredEvent - Event instance containing additional information about the delivered text.

Returns

  • N/A

Example

DataChannelEventListener dataChannelEventListener = new DefaultDataChannelEventListener() {
    @Override
    public void onTextDelivered(TextDeliveredEvent textDeliveredEvent) {
        if (textDeliveredEvent.isDelivered()) {
            Log.d("WebRTC", String.format("Successfully delivered text with id: %s", textDeliveredEvent.getId()));
        } else {
            Log.e("WebRTC", String.format("Failed to deliver text with id: %s", textDeliveredEvent.getId()));
        }
    }
});



onTextReceived(textReceivedEvent)

Description

Method that is triggered when the new text has been received.

Arguments

  • textReceivedEvent: TextReceivedEvent - Event instance containing additional information about the received text.

Returns

  • N/A

Example

DataChannelEventListener dataChannelEventListener = new DefaultDataChannelEventListener() {
    @Override
    public void onTextReceived(TextReceivedEvent textReceivedEvent) {
        if (textReceivedEvent.isDirect()) {
            Log.d("WebRTC", String.format("Received direct text from %s: %s", textReceivedEvent.getFrom().identifier(), textReceivedEvent.getText()));
        } else {
            Log.d("WebRTC", String.format("Received text from %s: %s", textReceivedEvent.getFrom().identifier(), textReceivedEvent.getText()));
        }
    }
});



onBroadcastTextReceived(broadcastTextReceivedEvent)

Description

Method triggered when a broadcast has been received. A broadcast is a message that is sent to all conference or dialog participants with an open DataChannel by invoking Calls API methods for conferences and dialogs respectively.

Arguments

  • broadcastTextReceivedEvent: BroadcastTextReceivedEvent - Event instance containing additional information about the received broadcasted text.

Returns

  • N/A

Example

DataChannelEventListener dataChannelEventListener = new DefaultDataChannelEventListener() {
    @Override
    public void onBroadcastTextReceived(BroadcastTextReceivedEvent broadcastTextReceivedEvent) {
        Log.d("WebRTC", String.format("Received broadcasted text: %s", broadcastTextReceivedEvent.getText()));
    }
});

Tutorials

Migration guides

Reference documentation

Clone this wiki locally