@Override public void onWaveletAdded(ObservableWavelet wavelet) { String id = ModernIdSerialiser.INSTANCE.serialiseWaveletId(wavelet.getId()); if (channels.containsKey(id)) { connect(id); } else { // This will trigger the onOperationChannelCreated callback below. mux.createOperationChannel(wavelet.getId(), wavelet.getCreatorId()); } }
@Override public void onOperationChannelCreated( OperationChannel channel, ObservableWaveletData snapshot, Accessibility accessibility) { WaveletId wid = snapshot.getWaveletId(); String id = ModernIdSerialiser.INSTANCE.serialiseWaveletId(wid); Preconditions.checkState(!channels.containsKey(id)); channels.put(id, channel); if (wave.getWavelet(wid) != null) { connect(id); } else { // This will trigger the onWaveletAdded callback above. wave.addWavelet(operationalizer.operationalize(snapshot)); } }
/** * Serializes a snapshot for a wavelet. * * @param wavelet wavelet to snapshot * @param hashedVersion hashed version of the wavelet * @return a wavelet snapshot that contains all the information in the original wavelet. */ public static WaveletSnapshot serializeWavelet( ReadableWaveletData wavelet, HashedVersion hashedVersion) { WaveletSnapshot.Builder builder = WaveletSnapshot.newBuilder(); builder.setWaveletId(ModernIdSerialiser.INSTANCE.serialiseWaveletId(wavelet.getWaveletId())); for (ParticipantId participant : wavelet.getParticipants()) { builder.addParticipantId(participant.toString()); } for (String id : wavelet.getDocumentIds()) { ReadableBlipData data = wavelet.getDocument(id); builder.addDocument(serializeDocument(data)); } builder.setVersion(CoreWaveletOperationSerializer.serialize(hashedVersion)); builder.setLastModifiedTime(wavelet.getLastModifiedTime()); builder.setCreator(wavelet.getCreator().getAddress()); builder.setCreationTime(wavelet.getCreationTime()); return builder.build(); }