Interface RoomObserver
-
@API(type=NOT_EXTENDABLE, src=PUBLIC) public interface RoomObserver
Observer for aRoom
, whose state can be used as a source of truth for the current state of the edited document.- Since:
- 23
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
RoomObserver.EditListener
Listener called when an edit happened in the room.static interface
RoomObserver.SyncListener
Listener called when a batch of changes are synchronized.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
ROOM_ID_HEADER
The name of the header that contains the room ID in theUserContext
of the observer.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addEditListener(RoomObserver.EditListener listener)
Register an edit listener.java.io.InputStream
createInputStream()
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.UserContext
getUserContext()
Sometimes, the room observer needs to open URL connections to fetch resourced referenced in the editor.void
removeEditListener(RoomObserver.EditListener listener)
Unregister an edit listener.void
sync(RoomObserver.SyncListener listener)
Synchronizes the Observer's state with the latest changes in the room.
-
-
-
Field Detail
-
ROOM_ID_HEADER
static final java.lang.String ROOM_ID_HEADER
The name of the header that contains the room ID in theUserContext
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, theURLStreamHandlerWithContext
instance will receive thisUserContext
. TheUserContext
has the "service account" flag set to true and a headerROOM_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.
-
-