Package com.google.collide.dto.server.DtoServerImpls

Examples of com.google.collide.dto.server.DtoServerImpls.WorkspaceTreeUpdateBroadcastImpl


    JsonArray messageModify = new JsonArray();
    message.putArray("delete", messageDelete);
    message.putArray("modify", messageModify);

    // Broadcast a tree mutation to all clients.
    WorkspaceTreeUpdateBroadcastImpl broadcast = WorkspaceTreeUpdateBroadcastImpl.make();

    for (NodeInfoExt node : adds) {
      System.out.println("add: " + pathString(node));
      // Edit session doesn't care.
      // Broadcast to clients.
      MutationImpl mutation =
          MutationImpl.make().setMutationType(Mutation.Type.ADD).setNewPath(pathString(node));
      /*
       * Do not strip the node; in the case of a newly scanned directory (e.g. recursive copy), its
       * children to not get their own mutations, it's just a single tree.
       */
      mutation.setNewNodeInfo((TreeNodeInfoImpl) node);
      broadcast.getMutations().add(mutation);
    }
    for (NodeInfoExt node : removes) {
      System.out.println("del: " + pathString(node));
      // Edit session wants deletes.
      messageDelete.addString(node.getFileEditSessionKey());
      // Broadcast to clients.
      MutationImpl mutation =
          MutationImpl.make().setMutationType(Mutation.Type.DELETE).setOldPath(pathString(node));
      broadcast.getMutations().add(mutation);
    }
    for (ExpectedMove move : completedMoves) {
      System.out.println("mov: " + pathString(move.oldNode) + " to: " + pathString(move.newNode));
      // Edit session doesn't care.
      // Broadcast to clients.
      MutationImpl mutation = MutationImpl.make()
          .setMutationType(Mutation.Type.MOVE).setNewPath(pathString(move.newNode))
          .setOldPath(pathString(move.oldNode));
      // Strip the node; the client should already have the children.
      mutation.setNewNodeInfo(stripChildren(move.newNode));
      broadcast.getMutations().add(mutation);
    }
    for (NodeInfoExt node : modifies) {
      System.out.println("mod: " + pathString(node));
      // Edit session wants modifies.
      messageModify.addString(node.getFileEditSessionKey());
      // No broadcast, edit session will handle.
    }
    vertx.eventBus().send("documents.fileSystemEvents", message);
    if (treeDirty) {
      broadcast.setNewTreeVersion(Long.toString(treeVersion));
      vertx.eventBus().send("participants.broadcast", new JsonObject().putString(
          Participants.PAYLOAD_TAG, broadcast.toJson()));
    }
  }
View Full Code Here

TOP

Related Classes of com.google.collide.dto.server.DtoServerImpls.WorkspaceTreeUpdateBroadcastImpl

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.