Package 

Interface Chat


  • 
    public interface Chat
    
                        

    Interface for managing chat activity.

    To get instance of this class use getChat

    • Method Detail

      • sendMessage

         abstract void sendMessage(String message, MessageAttachment attachment, RequestCallback<VisitorMessage> callback)

        Sends a chat message with an attachment to the Operator.

        Usage example:

         engagement.getChat().sendMessage(messageContent, attachment, (visitorMessage, exception) -> { if (exception != null) { // failed to send message return; } // message sent }); 
        

        Note, MESSAGE event triggers once request succeeds.See on for managing Chat events.

        Parameters:
        message - The content of the message that should be sent to the Operator
        attachment - The attachment that will be added to the message
        callback - The callback called with VisitorMessage instance when request succeedsor with GliaException.
      • sendMessagePreview

         abstract void sendMessagePreview(String message)

        Sends a message preview to the Operator.

        The latest preview message is always visible to the Operator. This means that Operators can use thepreview messages as an indication of Visitor activity. The Operator could also use the preview messages tostart preparing a response before the Visitor finishes typing, ensuring a fast and seamless communicationexperience.

        Usage example:

         editText.addTextChangedListener(new TextWatcher() { {@literal @}Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } {@literal @}Override public void onTextChanged(CharSequence s, int start, int before, int count) { } {@literal @}Override public void afterTextChanged(Editable message) { engagement.getChat().sendMessagePreview(message.toString()); } } 
        
        Parameters:
        message - message that currently is being typed by Visitor
      • on

         abstract <T> void on(Chat.ChatEvent<T> event, Consumer<T> listener)

        Registers event listeners for Chat.

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

        If multiple identical listeners are registered on the same event typethe duplicate instances are discarded. They do not cause the listenerto be called twice and do not need to be removed with the off or off method.

        Parameters:
        event - One of Events
        listener - Event listener to register
      • off

         abstract <T> void off(Chat.ChatEvent<T> event, Consumer<T> listener)

        Removes event listeners from the Chat.

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

        Calling {@code off} with arguments which do not identify any currently registeredlistener has no effect.

        Parameters:
        event - One of Events
        listener - Event listener to remove
      • off

         abstract <T> void off(Chat.ChatEvent<T> event)

        Removes all event listeners from Chat.

        Behaves the same way as off but removes all listeners of specified type

        Parameters:
        event - One of Events