isRecovering = true;
Log.info(getClass(), "Recovering from disconnection");
// 1) Gather potentially unacked doc ops
final ClientToServerDocOpImpl lastSentMsg =
lastSentDocOpProvider.getLastClientToServerDocOpMsg();
/*
* 2) Pause processing of incoming doc ops and queue them instead. This allows us, in the
* future, to apply the queued doc ops after recovery (the recovery response may not have
* contained some of the queued doc ops depending on the order the XHR and doc ops being
* processed by the server.)
*/
docOpReceiver.pause();
// 3) Perform recovery XHR
/*
* If we had unacked doc ops, we must use their intended version since that
* is the version of the document to which the unacked doc ops apply
* cleanly. If there aren't any unacked doc ops, we can use the latest
* version of the document that we have. (These can differ if we received
* doc ops while still waiting for our ack.)
*
* The unacked doc ops' intended version will always be less than or equal
* to the latest version we have received. When applying the returned doc
* ops from the document history, we will skip those that have already been
* applied.
*/
int revision = lastSentMsg != null ? lastSentMsg.getCcRevision() : revisionProvider.revision();
RecoverFromMissedDocOpsImpl recoveryDto =
RecoverFromMissedDocOpsImpl.make()
.setClientId(BootstrapSession.getBootstrapSession().getActiveClientId())
.setCurrentCcRevision(revision)
.setFileEditSessionKey(fileEditSessionKey);
if (lastSentMsg != null) {
recoveryDto.setDocOps2((JsoArray<String>) lastSentMsg.getDocOps2());
}
recoverFrontendApi.send(recoveryDto,
new ApiCallback<RecoverFromMissedDocOpsResponse>() {
@Override