mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-20 06:39:54 +01:00
Created expiry update and expiry ack packets for BMP.
This commit is contained in:
15
briar-api/src/net/sf/briar/api/protocol/ExpiryAck.java
Normal file
15
briar-api/src/net/sf/briar/api/protocol/ExpiryAck.java
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
package net.sf.briar.api.protocol;
|
||||||
|
|
||||||
|
/** A packet acknowledging a (@link ExpiryUpdate} */
|
||||||
|
public class ExpiryAck {
|
||||||
|
|
||||||
|
private final long version;
|
||||||
|
|
||||||
|
public ExpiryAck(long version) {
|
||||||
|
this.version = version;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getVersionNumber() {
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
}
|
||||||
23
briar-api/src/net/sf/briar/api/protocol/ExpiryUpdate.java
Normal file
23
briar-api/src/net/sf/briar/api/protocol/ExpiryUpdate.java
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
package net.sf.briar.api.protocol;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A packet updating the recipient's view of the expiry time of the sender's
|
||||||
|
* database.
|
||||||
|
*/
|
||||||
|
public class ExpiryUpdate {
|
||||||
|
|
||||||
|
private final long expiry, version;
|
||||||
|
|
||||||
|
public ExpiryUpdate(long expiry, long version) {
|
||||||
|
this.expiry = expiry;
|
||||||
|
this.version = version;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getExpiryTime() {
|
||||||
|
return expiry;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getVersionNumber() {
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,6 +9,12 @@ public interface ProtocolReader {
|
|||||||
boolean hasAck() throws IOException;
|
boolean hasAck() throws IOException;
|
||||||
Ack readAck() throws IOException;
|
Ack readAck() throws IOException;
|
||||||
|
|
||||||
|
boolean hasExpiryAck() throws IOException;
|
||||||
|
ExpiryAck readExpiryAck() throws IOException;
|
||||||
|
|
||||||
|
boolean hasExpiryUpdate() throws IOException;
|
||||||
|
ExpiryUpdate readExpiryUpdate() throws IOException;
|
||||||
|
|
||||||
boolean hasMessage() throws IOException;
|
boolean hasMessage() throws IOException;
|
||||||
UnverifiedMessage readMessage() throws IOException;
|
UnverifiedMessage readMessage() throws IOException;
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,10 @@ public interface ProtocolWriter {
|
|||||||
|
|
||||||
void writeAck(Ack a) throws IOException;
|
void writeAck(Ack a) throws IOException;
|
||||||
|
|
||||||
|
void writeExpiryAck(ExpiryAck a) throws IOException;
|
||||||
|
|
||||||
|
void writeExpiryUpdate(ExpiryUpdate e) throws IOException;
|
||||||
|
|
||||||
void writeMessage(byte[] raw) throws IOException;
|
void writeMessage(byte[] raw) throws IOException;
|
||||||
|
|
||||||
void writeOffer(Offer o) throws IOException;
|
void writeOffer(Offer o) throws IOException;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package net.sf.briar.api.protocol;
|
|||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
/** A packet updating the sender's subscriptions. */
|
/** A packet updating the recipient's view of the sender's subscriptions. */
|
||||||
public class SubscriptionUpdate {
|
public class SubscriptionUpdate {
|
||||||
|
|
||||||
private final Collection<Group> subs;
|
private final Collection<Group> subs;
|
||||||
|
|||||||
@@ -2,7 +2,9 @@ package net.sf.briar.api.protocol;
|
|||||||
|
|
||||||
import net.sf.briar.api.TransportProperties;
|
import net.sf.briar.api.TransportProperties;
|
||||||
|
|
||||||
/** A packet updating the sender's transport properties. */
|
/**
|
||||||
|
* A packet updating the recipient's view of the sender's transport properties.
|
||||||
|
*/
|
||||||
public class TransportUpdate {
|
public class TransportUpdate {
|
||||||
|
|
||||||
private final TransportId id;
|
private final TransportId id;
|
||||||
|
|||||||
@@ -3,14 +3,16 @@ package net.sf.briar.api.protocol;
|
|||||||
/** Struct identifiers for encoding and decoding protocol objects. */
|
/** Struct identifiers for encoding and decoding protocol objects. */
|
||||||
public interface Types {
|
public interface Types {
|
||||||
|
|
||||||
int ACK = 0;
|
int AUTHOR = 0;
|
||||||
int AUTHOR = 1;
|
int GROUP = 1;
|
||||||
int GROUP = 3;
|
int ACK = 2;
|
||||||
int MESSAGE = 4;
|
int EXPIRY_ACK = 3;
|
||||||
int OFFER = 5;
|
int EXPIRY_UPDATE = 4;
|
||||||
int REQUEST = 6;
|
int MESSAGE = 5;
|
||||||
int SUBSCRIPTION_ACK = 7;
|
int OFFER = 6;
|
||||||
int SUBSCRIPTION_UPDATE = 8;
|
int REQUEST = 7;
|
||||||
int TRANSPORT_ACK = 9;
|
int SUBSCRIPTION_ACK = 8;
|
||||||
int TRANSPORT_UPDATE = 10;
|
int SUBSCRIPTION_UPDATE = 9;
|
||||||
|
int TRANSPORT_ACK = 10;
|
||||||
|
int TRANSPORT_UPDATE = 11;
|
||||||
}
|
}
|
||||||
|
|||||||
20
briar-core/src/net/sf/briar/protocol/ExpiryAckReader.java
Normal file
20
briar-core/src/net/sf/briar/protocol/ExpiryAckReader.java
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
package net.sf.briar.protocol;
|
||||||
|
|
||||||
|
import static net.sf.briar.api.protocol.Types.EXPIRY_ACK;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import net.sf.briar.api.FormatException;
|
||||||
|
import net.sf.briar.api.protocol.ExpiryAck;
|
||||||
|
import net.sf.briar.api.serial.Reader;
|
||||||
|
import net.sf.briar.api.serial.StructReader;
|
||||||
|
|
||||||
|
class ExpiryAckReader implements StructReader<ExpiryAck> {
|
||||||
|
|
||||||
|
public ExpiryAck readStruct(Reader r) throws IOException {
|
||||||
|
r.readStructId(EXPIRY_ACK);
|
||||||
|
long version = r.readInt64();
|
||||||
|
if(version < 0L) throw new FormatException();
|
||||||
|
return new ExpiryAck(version);
|
||||||
|
}
|
||||||
|
}
|
||||||
22
briar-core/src/net/sf/briar/protocol/ExpiryUpdateReader.java
Normal file
22
briar-core/src/net/sf/briar/protocol/ExpiryUpdateReader.java
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
package net.sf.briar.protocol;
|
||||||
|
|
||||||
|
import static net.sf.briar.api.protocol.Types.EXPIRY_UPDATE;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import net.sf.briar.api.FormatException;
|
||||||
|
import net.sf.briar.api.protocol.ExpiryUpdate;
|
||||||
|
import net.sf.briar.api.serial.Reader;
|
||||||
|
import net.sf.briar.api.serial.StructReader;
|
||||||
|
|
||||||
|
class ExpiryUpdateReader implements StructReader<ExpiryUpdate> {
|
||||||
|
|
||||||
|
public ExpiryUpdate readStruct(Reader r) throws IOException {
|
||||||
|
r.readStructId(EXPIRY_UPDATE);
|
||||||
|
long expiry = r.readInt64();
|
||||||
|
if(expiry < 0L) throw new FormatException();
|
||||||
|
long version = r.readInt64();
|
||||||
|
if(version < 0L) throw new FormatException();
|
||||||
|
return new ExpiryUpdate(expiry, version);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,8 +5,6 @@ import static net.sf.briar.api.protocol.ProtocolConstants.MAX_PACKET_LENGTH;
|
|||||||
import static net.sf.briar.api.protocol.ProtocolConstants.MAX_SIGNATURE_LENGTH;
|
import static net.sf.briar.api.protocol.ProtocolConstants.MAX_SIGNATURE_LENGTH;
|
||||||
import static net.sf.briar.api.protocol.ProtocolConstants.MAX_SUBJECT_LENGTH;
|
import static net.sf.briar.api.protocol.ProtocolConstants.MAX_SUBJECT_LENGTH;
|
||||||
import static net.sf.briar.api.protocol.ProtocolConstants.SALT_LENGTH;
|
import static net.sf.briar.api.protocol.ProtocolConstants.SALT_LENGTH;
|
||||||
import static net.sf.briar.api.protocol.Types.AUTHOR;
|
|
||||||
import static net.sf.briar.api.protocol.Types.GROUP;
|
|
||||||
import static net.sf.briar.api.protocol.Types.MESSAGE;
|
import static net.sf.briar.api.protocol.Types.MESSAGE;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -51,22 +49,12 @@ class MessageReader implements StructReader<UnverifiedMessage> {
|
|||||||
}
|
}
|
||||||
// Read the group, if there is one
|
// Read the group, if there is one
|
||||||
Group group = null;
|
Group group = null;
|
||||||
if(r.hasNull()) {
|
if(r.hasNull()) r.readNull();
|
||||||
r.readNull();
|
else group = groupReader.readStruct(r);
|
||||||
} else {
|
|
||||||
r.addStructReader(GROUP, groupReader);
|
|
||||||
group = r.readStruct(GROUP, Group.class);
|
|
||||||
r.removeStructReader(GROUP);
|
|
||||||
}
|
|
||||||
// Read the author, if there is one
|
// Read the author, if there is one
|
||||||
Author author = null;
|
Author author = null;
|
||||||
if(r.hasNull()) {
|
if(r.hasNull()) r.readNull();
|
||||||
r.readNull();
|
else author = authorReader.readStruct(r);
|
||||||
} else {
|
|
||||||
r.addStructReader(AUTHOR, authorReader);
|
|
||||||
author = r.readStruct(AUTHOR, Author.class);
|
|
||||||
r.removeStructReader(AUTHOR);
|
|
||||||
}
|
|
||||||
// Read the subject
|
// Read the subject
|
||||||
String subject = r.readString(MAX_SUBJECT_LENGTH);
|
String subject = r.readString(MAX_SUBJECT_LENGTH);
|
||||||
// Read the timestamp
|
// Read the timestamp
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ import net.sf.briar.api.crypto.CryptoComponent;
|
|||||||
import net.sf.briar.api.protocol.Ack;
|
import net.sf.briar.api.protocol.Ack;
|
||||||
import net.sf.briar.api.protocol.Author;
|
import net.sf.briar.api.protocol.Author;
|
||||||
import net.sf.briar.api.protocol.AuthorFactory;
|
import net.sf.briar.api.protocol.AuthorFactory;
|
||||||
|
import net.sf.briar.api.protocol.ExpiryAck;
|
||||||
|
import net.sf.briar.api.protocol.ExpiryUpdate;
|
||||||
import net.sf.briar.api.protocol.Group;
|
import net.sf.briar.api.protocol.Group;
|
||||||
import net.sf.briar.api.protocol.GroupFactory;
|
import net.sf.briar.api.protocol.GroupFactory;
|
||||||
import net.sf.briar.api.protocol.MessageFactory;
|
import net.sf.briar.api.protocol.MessageFactory;
|
||||||
@@ -58,11 +60,6 @@ public class ProtocolModule extends AbstractModule {
|
|||||||
MIN_VERIFIER_THREADS, MAX_VERIFIER_THREADS));
|
MIN_VERIFIER_THREADS, MAX_VERIFIER_THREADS));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
|
||||||
StructReader<Ack> getAckReader() {
|
|
||||||
return new AckReader();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
StructReader<Author> getAuthorReader(CryptoComponent crypto) {
|
StructReader<Author> getAuthorReader(CryptoComponent crypto) {
|
||||||
return new AuthorReader(crypto);
|
return new AuthorReader(crypto);
|
||||||
@@ -73,6 +70,21 @@ public class ProtocolModule extends AbstractModule {
|
|||||||
return new GroupReader(crypto);
|
return new GroupReader(crypto);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
StructReader<Ack> getAckReader() {
|
||||||
|
return new AckReader();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
StructReader<ExpiryAck> getExpiryAckReader() {
|
||||||
|
return new ExpiryAckReader();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
StructReader<ExpiryUpdate> getExpiryUpdateReader() {
|
||||||
|
return new ExpiryUpdateReader();
|
||||||
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
StructReader<UnverifiedMessage> getMessageReader(
|
StructReader<UnverifiedMessage> getMessageReader(
|
||||||
StructReader<Group> groupReader,
|
StructReader<Group> groupReader,
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ package net.sf.briar.protocol;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
import net.sf.briar.api.protocol.Ack;
|
import net.sf.briar.api.protocol.Ack;
|
||||||
|
import net.sf.briar.api.protocol.ExpiryAck;
|
||||||
|
import net.sf.briar.api.protocol.ExpiryUpdate;
|
||||||
import net.sf.briar.api.protocol.Offer;
|
import net.sf.briar.api.protocol.Offer;
|
||||||
import net.sf.briar.api.protocol.ProtocolReader;
|
import net.sf.briar.api.protocol.ProtocolReader;
|
||||||
import net.sf.briar.api.protocol.ProtocolReaderFactory;
|
import net.sf.briar.api.protocol.ProtocolReaderFactory;
|
||||||
@@ -23,6 +25,8 @@ class ProtocolReaderFactoryImpl implements ProtocolReaderFactory {
|
|||||||
|
|
||||||
private final ReaderFactory readerFactory;
|
private final ReaderFactory readerFactory;
|
||||||
private final Provider<StructReader<Ack>> ackProvider;
|
private final Provider<StructReader<Ack>> ackProvider;
|
||||||
|
private final Provider<StructReader<ExpiryAck>> expiryAckProvider;
|
||||||
|
private final Provider<StructReader<ExpiryUpdate>> expiryUpdateProvider;
|
||||||
private final Provider<StructReader<UnverifiedMessage>> messageProvider;
|
private final Provider<StructReader<UnverifiedMessage>> messageProvider;
|
||||||
private final Provider<StructReader<Offer>> offerProvider;
|
private final Provider<StructReader<Offer>> offerProvider;
|
||||||
private final Provider<StructReader<Request>> requestProvider;
|
private final Provider<StructReader<Request>> requestProvider;
|
||||||
@@ -35,6 +39,8 @@ class ProtocolReaderFactoryImpl implements ProtocolReaderFactory {
|
|||||||
ProtocolReaderFactoryImpl(ReaderFactory readerFactory,
|
ProtocolReaderFactoryImpl(ReaderFactory readerFactory,
|
||||||
Provider<StructReader<Ack>> ackProvider,
|
Provider<StructReader<Ack>> ackProvider,
|
||||||
Provider<StructReader<UnverifiedMessage>> messageProvider,
|
Provider<StructReader<UnverifiedMessage>> messageProvider,
|
||||||
|
Provider<StructReader<ExpiryAck>> expiryAckProvider,
|
||||||
|
Provider<StructReader<ExpiryUpdate>> expiryUpdateProvider,
|
||||||
Provider<StructReader<Offer>> offerProvider,
|
Provider<StructReader<Offer>> offerProvider,
|
||||||
Provider<StructReader<Request>> requestProvider,
|
Provider<StructReader<Request>> requestProvider,
|
||||||
Provider<StructReader<SubscriptionAck>> subscriptionAckProvider,
|
Provider<StructReader<SubscriptionAck>> subscriptionAckProvider,
|
||||||
@@ -43,6 +49,8 @@ class ProtocolReaderFactoryImpl implements ProtocolReaderFactory {
|
|||||||
Provider<StructReader<TransportUpdate>> transportUpdateProvider) {
|
Provider<StructReader<TransportUpdate>> transportUpdateProvider) {
|
||||||
this.readerFactory = readerFactory;
|
this.readerFactory = readerFactory;
|
||||||
this.ackProvider = ackProvider;
|
this.ackProvider = ackProvider;
|
||||||
|
this.expiryAckProvider = expiryAckProvider;
|
||||||
|
this.expiryUpdateProvider = expiryUpdateProvider;
|
||||||
this.messageProvider = messageProvider;
|
this.messageProvider = messageProvider;
|
||||||
this.offerProvider = offerProvider;
|
this.offerProvider = offerProvider;
|
||||||
this.requestProvider = requestProvider;
|
this.requestProvider = requestProvider;
|
||||||
@@ -54,6 +62,7 @@ class ProtocolReaderFactoryImpl implements ProtocolReaderFactory {
|
|||||||
|
|
||||||
public ProtocolReader createProtocolReader(InputStream in) {
|
public ProtocolReader createProtocolReader(InputStream in) {
|
||||||
return new ProtocolReaderImpl(in, readerFactory, ackProvider.get(),
|
return new ProtocolReaderImpl(in, readerFactory, ackProvider.get(),
|
||||||
|
expiryAckProvider.get(), expiryUpdateProvider.get(),
|
||||||
messageProvider.get(), offerProvider.get(),
|
messageProvider.get(), offerProvider.get(),
|
||||||
requestProvider.get(), subscriptionAckProvider.get(),
|
requestProvider.get(), subscriptionAckProvider.get(),
|
||||||
subscriptionUpdateProvider.get(), transportAckProvider.get(),
|
subscriptionUpdateProvider.get(), transportAckProvider.get(),
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package net.sf.briar.protocol;
|
package net.sf.briar.protocol;
|
||||||
|
|
||||||
import static net.sf.briar.api.protocol.Types.ACK;
|
import static net.sf.briar.api.protocol.Types.ACK;
|
||||||
|
import static net.sf.briar.api.protocol.Types.EXPIRY_ACK;
|
||||||
|
import static net.sf.briar.api.protocol.Types.EXPIRY_UPDATE;
|
||||||
import static net.sf.briar.api.protocol.Types.MESSAGE;
|
import static net.sf.briar.api.protocol.Types.MESSAGE;
|
||||||
import static net.sf.briar.api.protocol.Types.OFFER;
|
import static net.sf.briar.api.protocol.Types.OFFER;
|
||||||
import static net.sf.briar.api.protocol.Types.REQUEST;
|
import static net.sf.briar.api.protocol.Types.REQUEST;
|
||||||
@@ -13,6 +15,8 @@ import java.io.IOException;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
import net.sf.briar.api.protocol.Ack;
|
import net.sf.briar.api.protocol.Ack;
|
||||||
|
import net.sf.briar.api.protocol.ExpiryAck;
|
||||||
|
import net.sf.briar.api.protocol.ExpiryUpdate;
|
||||||
import net.sf.briar.api.protocol.Offer;
|
import net.sf.briar.api.protocol.Offer;
|
||||||
import net.sf.briar.api.protocol.ProtocolReader;
|
import net.sf.briar.api.protocol.ProtocolReader;
|
||||||
import net.sf.briar.api.protocol.Request;
|
import net.sf.briar.api.protocol.Request;
|
||||||
@@ -31,6 +35,8 @@ class ProtocolReaderImpl implements ProtocolReader {
|
|||||||
|
|
||||||
ProtocolReaderImpl(InputStream in, ReaderFactory readerFactory,
|
ProtocolReaderImpl(InputStream in, ReaderFactory readerFactory,
|
||||||
StructReader<Ack> ackReader,
|
StructReader<Ack> ackReader,
|
||||||
|
StructReader<ExpiryAck> expiryAckReader,
|
||||||
|
StructReader<ExpiryUpdate> expiryUpdateReader,
|
||||||
StructReader<UnverifiedMessage> messageReader,
|
StructReader<UnverifiedMessage> messageReader,
|
||||||
StructReader<Offer> offerReader,
|
StructReader<Offer> offerReader,
|
||||||
StructReader<Request> requestReader,
|
StructReader<Request> requestReader,
|
||||||
@@ -43,6 +49,8 @@ class ProtocolReaderImpl implements ProtocolReader {
|
|||||||
reader.addStructReader(MESSAGE, messageReader);
|
reader.addStructReader(MESSAGE, messageReader);
|
||||||
reader.addStructReader(OFFER, offerReader);
|
reader.addStructReader(OFFER, offerReader);
|
||||||
reader.addStructReader(REQUEST, requestReader);
|
reader.addStructReader(REQUEST, requestReader);
|
||||||
|
reader.addStructReader(EXPIRY_ACK, expiryAckReader);
|
||||||
|
reader.addStructReader(EXPIRY_UPDATE, expiryUpdateReader);
|
||||||
reader.addStructReader(SUBSCRIPTION_ACK, subscriptionAckReader);
|
reader.addStructReader(SUBSCRIPTION_ACK, subscriptionAckReader);
|
||||||
reader.addStructReader(SUBSCRIPTION_UPDATE, subscriptionUpdateReader);
|
reader.addStructReader(SUBSCRIPTION_UPDATE, subscriptionUpdateReader);
|
||||||
reader.addStructReader(TRANSPORT_ACK, transportAckReader);
|
reader.addStructReader(TRANSPORT_ACK, transportAckReader);
|
||||||
@@ -61,6 +69,22 @@ class ProtocolReaderImpl implements ProtocolReader {
|
|||||||
return reader.readStruct(ACK, Ack.class);
|
return reader.readStruct(ACK, Ack.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasExpiryAck() throws IOException {
|
||||||
|
return reader.hasStruct(EXPIRY_ACK);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ExpiryAck readExpiryAck() throws IOException {
|
||||||
|
return reader.readStruct(EXPIRY_ACK, ExpiryAck.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasExpiryUpdate() throws IOException {
|
||||||
|
return reader.hasStruct(EXPIRY_UPDATE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ExpiryUpdate readExpiryUpdate() throws IOException {
|
||||||
|
return reader.readStruct(EXPIRY_UPDATE, ExpiryUpdate.class);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean hasMessage() throws IOException {
|
public boolean hasMessage() throws IOException {
|
||||||
return reader.hasStruct(MESSAGE);
|
return reader.hasStruct(MESSAGE);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package net.sf.briar.protocol;
|
|||||||
|
|
||||||
import static net.sf.briar.api.protocol.ProtocolConstants.MAX_PACKET_LENGTH;
|
import static net.sf.briar.api.protocol.ProtocolConstants.MAX_PACKET_LENGTH;
|
||||||
import static net.sf.briar.api.protocol.Types.ACK;
|
import static net.sf.briar.api.protocol.Types.ACK;
|
||||||
|
import static net.sf.briar.api.protocol.Types.EXPIRY_ACK;
|
||||||
|
import static net.sf.briar.api.protocol.Types.EXPIRY_UPDATE;
|
||||||
import static net.sf.briar.api.protocol.Types.GROUP;
|
import static net.sf.briar.api.protocol.Types.GROUP;
|
||||||
import static net.sf.briar.api.protocol.Types.OFFER;
|
import static net.sf.briar.api.protocol.Types.OFFER;
|
||||||
import static net.sf.briar.api.protocol.Types.REQUEST;
|
import static net.sf.briar.api.protocol.Types.REQUEST;
|
||||||
@@ -15,6 +17,8 @@ import java.io.OutputStream;
|
|||||||
import java.util.BitSet;
|
import java.util.BitSet;
|
||||||
|
|
||||||
import net.sf.briar.api.protocol.Ack;
|
import net.sf.briar.api.protocol.Ack;
|
||||||
|
import net.sf.briar.api.protocol.ExpiryAck;
|
||||||
|
import net.sf.briar.api.protocol.ExpiryUpdate;
|
||||||
import net.sf.briar.api.protocol.Group;
|
import net.sf.briar.api.protocol.Group;
|
||||||
import net.sf.briar.api.protocol.MessageId;
|
import net.sf.briar.api.protocol.MessageId;
|
||||||
import net.sf.briar.api.protocol.Offer;
|
import net.sf.briar.api.protocol.Offer;
|
||||||
@@ -70,6 +74,19 @@ class ProtocolWriterImpl implements ProtocolWriter {
|
|||||||
if(flush) out.flush();
|
if(flush) out.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void writeExpiryAck(ExpiryAck a) throws IOException {
|
||||||
|
w.writeStructId(EXPIRY_ACK);
|
||||||
|
w.writeInt64(a.getVersionNumber());
|
||||||
|
if(flush) out.flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void writeExpiryUpdate(ExpiryUpdate e) throws IOException {
|
||||||
|
w.writeStructId(EXPIRY_UPDATE);
|
||||||
|
w.writeInt64(e.getExpiryTime());
|
||||||
|
w.writeInt64(e.getVersionNumber());
|
||||||
|
if(flush) out.flush();
|
||||||
|
}
|
||||||
|
|
||||||
public void writeMessage(byte[] raw) throws IOException {
|
public void writeMessage(byte[] raw) throws IOException {
|
||||||
out.write(raw);
|
out.write(raw);
|
||||||
if(flush) out.flush();
|
if(flush) out.flush();
|
||||||
|
|||||||
Reference in New Issue
Block a user