mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 18:59:06 +01:00
Readers, writers and factories for subscription and transport updates.
This commit is contained in:
@@ -2,8 +2,10 @@ package net.sf.briar.api.protocol;
|
||||
|
||||
import java.security.PublicKey;
|
||||
|
||||
import net.sf.briar.api.serial.Writable;
|
||||
|
||||
/** A group to which users may subscribe. */
|
||||
public interface Group {
|
||||
public interface Group extends Writable {
|
||||
|
||||
/** Returns the group's unique identifier. */
|
||||
GroupId getId();
|
||||
|
||||
@@ -2,5 +2,6 @@ package net.sf.briar.api.protocol;
|
||||
|
||||
public interface GroupFactory {
|
||||
|
||||
Group createGroup(GroupId id, String name, boolean restricted, byte[] b);
|
||||
Group createGroup(GroupId id, String name, boolean restricted,
|
||||
byte[] saltOrKey);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,12 @@ import java.util.Collection;
|
||||
/** A packet updating the sender's subscriptions. */
|
||||
public interface Subscriptions {
|
||||
|
||||
/**
|
||||
* The maximum size of a serialized subscriptions update, excluding
|
||||
* encryption and authentication.
|
||||
*/
|
||||
static final int MAX_SIZE = (1024 * 1024) - 100;
|
||||
|
||||
/** Returns the subscriptions contained in the update. */
|
||||
Collection<Group> getSubscriptions();
|
||||
|
||||
|
||||
@@ -11,9 +11,10 @@ public interface Tags {
|
||||
static final int AUTHOR_ID = 1;
|
||||
static final int BATCH = 2;
|
||||
static final int BATCH_ID = 3;
|
||||
static final int GROUP_ID = 4;
|
||||
static final int MESSAGE = 5;
|
||||
static final int MESSAGE_ID = 6;
|
||||
static final int SUBSCRIPTIONS = 7;
|
||||
static final int TRANSPORTS = 8;
|
||||
static final int GROUP = 4;
|
||||
static final int GROUP_ID = 5;
|
||||
static final int MESSAGE = 6;
|
||||
static final int MESSAGE_ID = 7;
|
||||
static final int SUBSCRIPTIONS = 8;
|
||||
static final int TRANSPORTS = 9;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,12 @@ import java.util.Map;
|
||||
/** A packet updating the sender's transports. */
|
||||
public interface Transports {
|
||||
|
||||
/**
|
||||
* The maximum size of a serialised transports update, excluding
|
||||
* encryption and authentication.
|
||||
*/
|
||||
static final int MAX_SIZE = (1024 * 1024) - 100;
|
||||
|
||||
/** Returns the transports contained in the update. */
|
||||
Map<String, String> getTransports();
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ public interface AckWriter {
|
||||
* Attempts to add the given BatchId to the ack and returns true if it
|
||||
* was added.
|
||||
*/
|
||||
boolean addBatchId(BatchId b) throws IOException;
|
||||
boolean writeBatchId(BatchId b) throws IOException;
|
||||
|
||||
/** Finishes writing the ack. */
|
||||
void finish() throws IOException;
|
||||
|
||||
@@ -14,7 +14,7 @@ public interface BatchWriter {
|
||||
* Attempts to add the given raw message to the batch and returns true if
|
||||
* it was added.
|
||||
*/
|
||||
boolean addMessage(byte[] raw) throws IOException;
|
||||
boolean writeMessage(byte[] raw) throws IOException;
|
||||
|
||||
/** Finishes writing the batch and returns its unique identifier. */
|
||||
BatchId finish() throws IOException;
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
package net.sf.briar.api.protocol.writers;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
|
||||
import net.sf.briar.api.protocol.Group;
|
||||
|
||||
/** An interface for creating a subscription update. */
|
||||
public interface SubscriptionWriter {
|
||||
|
||||
/** Sets the contents of the update. */
|
||||
void setSubscriptions(Iterable<Group> subs) throws IOException;
|
||||
/** Writes the contents of the update. */
|
||||
void writeSubscriptions(Collection<Group> subs) throws IOException;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,6 @@ import java.util.Map;
|
||||
/** An interface for creating a transports update. */
|
||||
public interface TransportWriter {
|
||||
|
||||
/** Sets the contents of the update. */
|
||||
void setTransports(Map<String, String> transports) throws IOException;
|
||||
/** Writes the contents of the update. */
|
||||
void writeTransports(Map<String, String> transports) throws IOException;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user