public interface

IncomingEngagementRequest

implements EngagementRequest
com.glia.androidsdk.IncomingEngagementRequest

Class Overview

Provides ability to accept or decline EngagementRequest initiated by Operator.

EngagementRequest automatically times out if it is not accepted or declined by the Visitor within specified time frame.

If the request was successfully accepted then a respective ENGAGEMENT event is triggered with an instance of Engagement.

You can subscribe to on(EngagementRequestEvent, Consumer) with the Events#OUTCOME event to get notified of Engagement request result.

Example - accept or decline Engagement Request based on user action:

 Glia.omnibrowse.on(Omnibrowse.Events.ENGAGEMENT_REQUEST, engagementRequest -> {
     Consumer onResult = error -> {
         if (error != null) {
             // Handle error
         }
     };

     this.runOnUiThread(() -> {
         showEngagementRequestDialogToVisitor(() -> { // onAccept
             engagementRequest.accept(onResult);
         }, () -> { // onDecline
             engagementRequest.decline(onResult);
         });
     });
 });
 

Summary

Public Methods
abstract void accept(VisitorContext visitorContext, Consumer<GliaException> onResult)
Accepts this incoming Engagement Request.
abstract void decline(Consumer<GliaException> onResult)
Declines this incoming Engagement Request.
abstract String getId()
Returns Engagement Request unique ID
abstract Operator getOperator()
abstract Optional<EngagementRequest.Outcome> getOutcome()
Return Engagement request Optional EngagementRequest.Outcome which is one of EngagementRequest.Outcome values.
abstract void off(EngagementRequestEvent<? super Void> event, Runnable listener)
Removes event listeners from the Engagement Request.
abstract <T> void off(EngagementRequestEvent<T> event, Consumer<T> listener)
Removes event listeners from the Engagement Request.
abstract <T> void on(EngagementRequestEvent<T> event, Consumer<T> listener)
Registers event listeners for Engagement Request.
abstract void on(EngagementRequestEvent<? super Void> event, Runnable listener)
Registers event listeners for Engagement Request.
[Expand]
Inherited Methods
From interface com.glia.androidsdk.EngagementRequest

Public Methods

public abstract void accept (VisitorContext visitorContext, Consumer<GliaException> onResult)

Accepts this incoming Engagement Request.

Parameters
visitorContext Content that is displayed to the Operator during the Engagement. You may use it to display information that would give the Operator an additional context about the Visitor or any other content that might be helpful.
onResult Called with null on success or with GliaException if the process fails for any reason. The GliaException may have one of the following causes:
NETWORK_TIMEOUT - when request times out due to connection issues
INTERNAL_ERROR - when internal error occurs

public abstract void decline (Consumer<GliaException> onResult)

Declines this incoming Engagement Request.

Parameters
onResult Called with null on success or with GliaException if the process fails for any reason. The GliaException may have one of the following causes:
NETWORK_TIMEOUT - when request times out due to connection issues
INTERNAL_ERROR - when internal error occurs

public abstract String getId ()

Returns Engagement Request unique ID

public abstract Operator getOperator ()

Returns
  • The Operator who initiated the request

public abstract Optional<EngagementRequest.Outcome> getOutcome ()

Return Engagement request Optional EngagementRequest.Outcome which is one of EngagementRequest.Outcome values. If outcome is still undefined then it will return empty()

public abstract void off (EngagementRequestEvent<? super Void> event, Runnable listener)

Removes event listeners from the Engagement Request.

If an event listener is removed while the Engagement Request is processing an event, it is not triggered with the current event.

Calling off with arguments which do not identify any currently registered listener has no effect.

Parameters
event One of Events
listener Event listener to remove

public abstract void off (EngagementRequestEvent<T> event, Consumer<T> listener)

Removes event listeners from the Engagement Request.

If an event listener is removed while the Engagement Request is processing an event, it is not triggered with the current event.

Calling off with arguments which do not identify any currently registered listener has no effect.

Parameters
event One of Events
listener Event listener to remove

public abstract void on (EngagementRequestEvent<T> event, Consumer<T> listener)

Registers event listeners for Engagement Request.

If a listener is added while the Engagement Request is processing an event, it is not triggered with the current event.

If multiple identical listeners are registered on the same event type the duplicate instances are discarded. They do not cause the listener to be called twice and do not need to be removed with the off(EngagementRequest.EngagementRequestEvent, Runnable) method.

Parameters
event One of Events
listener Event listener to register

public abstract void on (EngagementRequestEvent<? super Void> event, Runnable listener)

Registers event listeners for Engagement Request.

If a listener is added while the Engagement Request is processing an event, it is not triggered with the current event.

If multiple identical listeners are registered on the same event type the duplicate instances are discarded. They do not cause the listener to be called twice and do not need to be removed with the off(EngagementRequest.EngagementRequestEvent, Runnable) method.

Compared to on(EngagementRequestEvent, Consumer) this method does not require the listener to consumer the payload. This is useful when payload is of type Void.

Parameters
event One of Events
listener Event listener to register