Skip to content

ReconnectHandler

Ajša Terko edited this page Oct 2, 2023 · 1 revision



prepareForReconnect(reconnectingCallId, reconnectingCallOptions)

Description

Method used to prepare the ApplicationCallOptions used for the reconnected call.

Generally, you can use this to add some custom data necessary for handling the flow of the reconnected call on your backend application, but you can also change other options (such as audio or video).

For example, you might add the reconnectingCallId to the custom data, which you can use on your backend application to check whether the old (reconnecting) call is still in conference, and kick it before connecting with the new (reconnected) call.

Another potential use case could be explicitly turning video off through the returned options.

Arguments

  • reconnectingCallId: String - The id of the old (reconnecting) call
  • reconnectingCallOptions: ApplicationCallOptions - The options representing the state the call was in when the reconnecting process started.

Returns

  • N/A

Example

public class ReconnectHandlerAdapter implements ReconnectHandler {
    @Override
    public ApplicationCallOptions prepareForReconnect(String reconnectingCallId, ApplicationCallOptions reconnectingCallOptions) {
        // Add any custom data that will help you handle the reconnect flow on your backend application
        Map<String, String> modifiedCustomData = reconnectingCallOptions.getCustomData();
        modifiedCustomData.put("reconnectingCallId", reconnectingCallId);
  
        // Optionally turn off the video
        ApplicationCallOptions applicationCallOptions = ApplicationCallOptions.builder()
                .audio(reconnectingCallOptions.getAudio())
                .audioOptions(reconnectingCallOptions.getAudioOptions())
                .video(false)
                .videoOptions(reconnectingCallOptions.getVideoOptions)
                .customData(modifiedCustomData)
                .dataChannel(reconnectingCallOptions.isDataChannel())
                .build();
  
        return applicationCallOptions;
    }
}

Tutorials

Migration guides

Reference documentation

Clone this wiki locally