mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-15 04:18:53 +01:00
Each request packet should contain the unique ID of the offer to which
it responds.
This commit is contained in:
@@ -11,6 +11,9 @@ public interface Offer {
|
||||
*/
|
||||
static final int MAX_SIZE = (1024 * 1024) - 100;
|
||||
|
||||
/** Returns the offer's unique identifier. */
|
||||
OfferId getId();
|
||||
|
||||
/** Returns the message IDs contained in the offer. */
|
||||
Collection<MessageId> getMessageIds();
|
||||
}
|
||||
|
||||
26
api/net/sf/briar/api/protocol/OfferId.java
Normal file
26
api/net/sf/briar/api/protocol/OfferId.java
Normal file
@@ -0,0 +1,26 @@
|
||||
package net.sf.briar.api.protocol;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
|
||||
import net.sf.briar.api.serial.Writer;
|
||||
|
||||
/** Type-safe wrapper for a byte array that uniquely identifies an offer. */
|
||||
public class OfferId extends UniqueId {
|
||||
|
||||
public OfferId(byte[] id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
public void writeTo(Writer w) throws IOException {
|
||||
w.writeUserDefinedTag(Tags.OFFER_ID);
|
||||
w.writeBytes(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if(o instanceof OfferId)
|
||||
return Arrays.equals(id, ((OfferId) o).id);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,12 @@ public interface Request {
|
||||
*/
|
||||
static final int MAX_SIZE = (1024 * 1024) - 100;
|
||||
|
||||
/**
|
||||
* Returns the unique identifier of the offer to which this request
|
||||
* responds.
|
||||
*/
|
||||
OfferId getOfferId();
|
||||
|
||||
/**
|
||||
* Returns a sequence of bits corresponding to the sequence of messages in
|
||||
* the offer, where the i^th bit is set if the i^th message should be sent.
|
||||
|
||||
@@ -17,7 +17,8 @@ public interface Tags {
|
||||
static final int MESSAGE = 7;
|
||||
static final int MESSAGE_ID = 8;
|
||||
static final int OFFER = 9;
|
||||
static final int REQUEST = 10;
|
||||
static final int SUBSCRIPTIONS = 11;
|
||||
static final int TRANSPORTS = 12;
|
||||
static final int OFFER_ID = 10;
|
||||
static final int REQUEST = 11;
|
||||
static final int SUBSCRIPTIONS = 12;
|
||||
static final int TRANSPORTS = 13;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package net.sf.briar.api.protocol.writers;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.sf.briar.api.protocol.MessageId;
|
||||
import net.sf.briar.api.protocol.OfferId;
|
||||
|
||||
/** An interface for creating a have notification. */
|
||||
public interface OfferWriter {
|
||||
@@ -13,6 +14,6 @@ public interface OfferWriter {
|
||||
*/
|
||||
boolean writeMessageId(MessageId m) throws IOException;
|
||||
|
||||
/** Finishes writing the offer. */
|
||||
void finish() throws IOException;
|
||||
/** Finishes writing the offer and returns its unique identifier. */
|
||||
OfferId finish() throws IOException;
|
||||
}
|
||||
|
||||
@@ -3,9 +3,11 @@ package net.sf.briar.api.protocol.writers;
|
||||
import java.io.IOException;
|
||||
import java.util.BitSet;
|
||||
|
||||
import net.sf.briar.api.protocol.OfferId;
|
||||
|
||||
/** An interface for creating a request packet. */
|
||||
public interface RequestWriter {
|
||||
|
||||
/** Writes the contents of the request. */
|
||||
void writeBitmap(BitSet b, int length) throws IOException;
|
||||
void writeRequest(OfferId offerId, BitSet b, int length) throws IOException;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user