Changed the format of transport properties from (key, value) pairs to

(transport name, key, value) triples. This makes it possible for each
transport plugin to update its locally stored properties atomically.
This commit is contained in:
akwizgran
2011-08-04 11:07:28 +01:00
parent 5be9d953ee
commit ec29c4d1d3
16 changed files with 264 additions and 172 deletions

View File

@@ -3,6 +3,7 @@ package net.sf.briar.protocol.writers;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Map;
import java.util.Map.Entry;
import net.sf.briar.api.protocol.Tags;
import net.sf.briar.api.protocol.writers.TransportWriter;
@@ -19,10 +20,21 @@ class TransportWriterImpl implements TransportWriter {
w = writerFactory.createWriter(out);
}
public void writeTransports(Map<String, String> transports)
public void writeTransports(Map<String, Map<String, String>> transports)
throws IOException {
w.writeUserDefinedTag(Tags.TRANSPORTS);
w.writeMap(transports);
// Transport maps are always written in delimited form
w.writeMapStart();
for(Entry<String, Map<String, String>> e : transports.entrySet()) {
w.writeString(e.getKey());
w.writeMapStart();
for(Entry<String, String> e1 : e.getValue().entrySet()) {
w.writeString(e1.getKey());
w.writeString(e1.getValue());
}
w.writeMapEnd();
}
w.writeMapEnd();
w.writeInt64(System.currentTimeMillis());
out.flush();
}