Massive refactoring to merge handling of simplex and duplex connections.

This commit is contained in:
akwizgran
2014-11-04 16:51:25 +00:00
parent b24f153704
commit 7b8181e309
67 changed files with 1981 additions and 2288 deletions

View File

@@ -2,18 +2,18 @@ package org.briarproject.api.transport;
import org.briarproject.api.ContactId;
import org.briarproject.api.TransportId;
import org.briarproject.api.plugins.TransportConnectionReader;
import org.briarproject.api.plugins.TransportConnectionWriter;
import org.briarproject.api.plugins.duplex.DuplexTransportConnection;
import org.briarproject.api.plugins.simplex.SimplexTransportReader;
import org.briarproject.api.plugins.simplex.SimplexTransportWriter;
public interface ConnectionDispatcher {
void dispatchIncomingConnection(TransportId t, SimplexTransportReader r);
void dispatchIncomingConnection(TransportId t, TransportConnectionReader r);
void dispatchIncomingConnection(TransportId t, DuplexTransportConnection d);
void dispatchOutgoingConnection(ContactId c, TransportId t,
SimplexTransportWriter w);
TransportConnectionWriter w);
void dispatchOutgoingConnection(ContactId c, TransportId t,
DuplexTransportConnection d);

View File

@@ -6,7 +6,7 @@ public interface StreamReaderFactory {
/** Creates a {@link StreamReader} for a transport connection. */
StreamReader createStreamReader(InputStream in, int maxFrameLength,
StreamContext ctx, boolean incoming, boolean initiator);
StreamContext ctx);
/** Creates a {@link StreamReader} for an invitation connection. */
StreamReader createInvitationStreamReader(InputStream in,

View File

@@ -10,10 +10,4 @@ public interface StreamWriter {
* be written.
*/
OutputStream getOutputStream();
/**
* Returns the maximum number of bytes that can be written to the output
* stream.
*/
long getRemainingCapacity();
}

View File

@@ -6,8 +6,7 @@ public interface StreamWriterFactory {
/** Creates a {@link StreamWriter} for a transport connection. */
StreamWriter createStreamWriter(OutputStream out, int maxFrameLength,
long capacity, StreamContext ctx, boolean incoming,
boolean initiator);
StreamContext ctx);
/** Creates a {@link StreamWriter} for an invitation connection. */
StreamWriter createInvitationStreamWriter(OutputStream out,

View File

@@ -4,12 +4,13 @@ import org.briarproject.api.ContactId;
import org.briarproject.api.TransportId;
import org.briarproject.api.db.DbException;
/** Maintains the table of expected tags for recognising incoming streams. */
/** Keeps track of expected tags and uses them to recognise incoming streams. */
public interface TagRecogniser {
/**
* Returns a {@link StreamContext} for reading from the stream with the
* given tag if the tag was expected, or null if the tag was unexpected.
* Looks up the given tag and returns a {@link StreamContext} for reading
* from the stream if the tag was expected, or null if the tag was
* unexpected.
*/
StreamContext recogniseTag(TransportId t, byte[] tag) throws DbException;