Package com.google.collide.dto.client.DtoClientImpls

Examples of com.google.collide.dto.client.DtoClientImpls.ClientToServerDocOpImpl


    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
View Full Code Here


       */
      JsoArray<String> docOps = JsoArray.create();
      for (int i = 0, n = operations.size(); i < n; i++) {
        docOps.add(Jso.serialize((DocOpImpl) operations.get(i)));
      }
      ClientToServerDocOpImpl message = ClientToServerDocOpImpl
          .make()
          .setFileEditSessionKey(fileEditSessionKey)
          .setCcRevision(revision)
          .setClientId(BootstrapSession.getBootstrapSession().getActiveClientId())
          .setDocOps2(docOps);

      if (clientToServerDocOpCreationParticipant != null) {
        clientToServerDocOpCreationParticipant.onCreateClientToServerDocOp(message);
      }

      frontendApi.MUTATE_FILE.send(message, new ApiCallback<ServerToClientDocOps>() {
        @Override
        public void onFail(FailureReason reason) {
          if (reason == FailureReason.MISSING_WORKSPACE_SESSION) {
            docOpRecoveryInitiator.teardown();
          } else {
            docOpRecoveryInitiator.recover();
          }
        }

        @Override
        public void onMessageReceived(ServerToClientDocOps message) {
          for (int i = 0; i < message.getDocOps().size(); i++) {
            docOpDemux.handleServerToClientDocOpMsg(
                (ServerToClientDocOpImpl) message.getDocOps().get(i));
          }
        }       
      });
     
      lastClientToServerDocOpMsg = message;
View Full Code Here

TOP

Related Classes of com.google.collide.dto.client.DtoClientImpls.ClientToServerDocOpImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.