mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 03:09:04 +01:00
Decoupled ProtocolReader (which belongs in the protocol component)
from PacketReader (which belongs in the transport component).
This commit is contained in:
24
api/net/sf/briar/api/protocol/ProtocolReader.java
Normal file
24
api/net/sf/briar/api/protocol/ProtocolReader.java
Normal file
@@ -0,0 +1,24 @@
|
||||
package net.sf.briar.api.protocol;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public interface ProtocolReader {
|
||||
|
||||
boolean hasAck() throws IOException;
|
||||
Ack readAck() throws IOException;
|
||||
|
||||
boolean hasBatch() throws IOException;
|
||||
Batch readBatch() throws IOException;
|
||||
|
||||
boolean hasOffer() throws IOException;
|
||||
Offer readOffer() throws IOException;
|
||||
|
||||
boolean hasRequest() throws IOException;
|
||||
Request readRequest() throws IOException;
|
||||
|
||||
boolean hasSubscriptionUpdate() throws IOException;
|
||||
SubscriptionUpdate readSubscriptionUpdate() throws IOException;
|
||||
|
||||
boolean hasTransportUpdate() throws IOException;
|
||||
TransportUpdate readTransportUpdate() throws IOException;
|
||||
}
|
||||
8
api/net/sf/briar/api/protocol/ProtocolReaderFactory.java
Normal file
8
api/net/sf/briar/api/protocol/ProtocolReaderFactory.java
Normal file
@@ -0,0 +1,8 @@
|
||||
package net.sf.briar.api.protocol;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
public interface ProtocolReaderFactory {
|
||||
|
||||
ProtocolReader createProtocolReader(InputStream in);
|
||||
}
|
||||
@@ -1,13 +1,8 @@
|
||||
package net.sf.briar.api.transport;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.sf.briar.api.protocol.Ack;
|
||||
import net.sf.briar.api.protocol.Batch;
|
||||
import net.sf.briar.api.protocol.Offer;
|
||||
import net.sf.briar.api.protocol.Request;
|
||||
import net.sf.briar.api.protocol.SubscriptionUpdate;
|
||||
import net.sf.briar.api.protocol.TransportUpdate;
|
||||
import java.io.InputStream;
|
||||
import java.security.GeneralSecurityException;
|
||||
|
||||
/**
|
||||
* Reads encrypted packets from an underlying input stream, decrypts and
|
||||
@@ -15,21 +10,17 @@ import net.sf.briar.api.protocol.TransportUpdate;
|
||||
*/
|
||||
public interface PacketReader {
|
||||
|
||||
boolean hasAck() throws IOException;
|
||||
Ack readAck() throws IOException;
|
||||
/**
|
||||
* Returns the input stream from which packets should be read. (Note that
|
||||
* this is not the underlying input stream.)
|
||||
*/
|
||||
InputStream getInputStream();
|
||||
|
||||
boolean hasBatch() throws IOException;
|
||||
Batch readBatch() throws IOException;
|
||||
|
||||
boolean hasOffer() throws IOException;
|
||||
Offer readOffer() throws IOException;
|
||||
|
||||
boolean hasRequest() throws IOException;
|
||||
Request readRequest() throws IOException;
|
||||
|
||||
boolean hasSubscriptionUpdate() throws IOException;
|
||||
SubscriptionUpdate readSubscriptionUpdate() throws IOException;
|
||||
|
||||
boolean hasTransportUpdate() throws IOException;
|
||||
TransportUpdate readTransportUpdate() throws IOException;
|
||||
/**
|
||||
* Finishes reading the current packet (if any), authenticates the packet
|
||||
* and prepares to read the next packet. If this method is called twice in
|
||||
* succession without any intervening reads, the underlying input stream
|
||||
* will be unaffected.
|
||||
*/
|
||||
void finishPacket() throws IOException, GeneralSecurityException;
|
||||
}
|
||||
|
||||
@@ -20,5 +20,5 @@ public interface PacketWriter {
|
||||
* next packet. If this method is called twice in succession without any
|
||||
* intervening writes, the underlying output stream will be unaffected.
|
||||
*/
|
||||
void nextPacket() throws IOException;
|
||||
void finishPacket() throws IOException;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user