Interface RoomObserver


  • @API(type=NOT_EXTENDABLE,
         src=PUBLIC)
    public interface RoomObserver
    Observer for a Room, whose state can be used as a source of truth for the current state of the edited document.
    Since:
    23
    • Field Detail

      • ROOM_ID_HEADER

        static final java.lang.String ROOM_ID_HEADER
        The name of the header that contains the room ID in the UserContext of the observer.
        See Also:
        Constant Field Values
    • Method Detail

      • sync

        void sync​(RoomObserver.SyncListener listener)
        Synchronizes the Observer's state with the latest changes in the room. The observer synchronizes its state with changes from multiple users that changed the document since the last sync. The observer tries to batch together as many changes from the same user as possible (without breaking causality of changes). After synchronizing changes from a single user the listener is called.
        Parameters:
        listener - The listener to call after synchronizing changes from an user.
      • createInputStream

        java.io.InputStream createInputStream()
                                       throws java.io.IOException
        Returns:
        The input stream over the current content of the observer.
        Throws:
        java.io.IOException - If the input stream cannot be created.
      • getUnsavedContentReferenceManager

        UnsavedContentReferenceManager getUnsavedContentReferenceManager()
        Get the manager that can be used to find (and save) the resources whose content has been modified in-place, by editing the expanded references.
        Returns:
        The unsaved references manager, or null if editing in references is not enabled.
      • getUserContext

        UserContext getUserContext()
        Sometimes, the room observer needs to open URL connections to fetch resourced referenced in the editor. When it opens such connections, the URLStreamHandlerWithContext instance will receive this UserContext. The UserContext has the "service account" flag set to true and a header ROOM_ID_HEADER that contains the ID of the room.
        Returns:
        the UserContext instance used when opening URL connections.
      • addEditListener

        void addEditListener​(RoomObserver.EditListener listener)
        Register an edit listener.
        Parameters:
        listener - The edit listener to register.
      • removeEditListener

        void removeEditListener​(RoomObserver.EditListener listener)
        Unregister an edit listener.
        Parameters:
        listener - The edit listener to register.