mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 10:49:06 +01:00
Refactoring.
Unidirectional transports and connections are now called simplex rather than batch. Bidirectional transports and connections are now called duplex rather than stream.
This commit is contained in:
@@ -1,50 +0,0 @@
|
||||
package net.sf.briar.api.plugins;
|
||||
|
||||
import net.sf.briar.api.ContactId;
|
||||
import net.sf.briar.api.transport.BatchTransportReader;
|
||||
import net.sf.briar.api.transport.BatchTransportWriter;
|
||||
|
||||
/**
|
||||
* An interface for transport plugins that do not support bidirectional,
|
||||
* reliable, ordered, timely delivery of data.
|
||||
*/
|
||||
public interface BatchPlugin extends Plugin {
|
||||
|
||||
/**
|
||||
* Attempts to create and return a BatchTransportReader for the given
|
||||
* contact using the current transport and configuration properties.
|
||||
* Returns null if a reader could not be created.
|
||||
*/
|
||||
BatchTransportReader createReader(ContactId c);
|
||||
|
||||
/**
|
||||
* Attempts to create and return a BatchTransportWriter for the given
|
||||
* contact using the current transport and configuration properties.
|
||||
* Returns null if a writer could not be created.
|
||||
*/
|
||||
BatchTransportWriter createWriter(ContactId c);
|
||||
|
||||
/**
|
||||
* Starts the invitation process from the inviter's side. Returns null if
|
||||
* no connection can be established within the given timeout.
|
||||
*/
|
||||
BatchTransportWriter sendInvitation(int code, long timeout);
|
||||
|
||||
/**
|
||||
* Starts the invitation process from the invitee's side. Returns null if
|
||||
* no connection can be established within the given timeout.
|
||||
*/
|
||||
BatchTransportReader acceptInvitation(int code, long timeout);
|
||||
|
||||
/**
|
||||
* Continues the invitation process from the invitee's side. Returns null
|
||||
* if no connection can be established within the given timeout.
|
||||
*/
|
||||
BatchTransportWriter sendInvitationResponse(int code, long timeout);
|
||||
|
||||
/**
|
||||
* Continues the invitation process from the inviter's side. Returns null
|
||||
* if no connection can be established within the given timeout.
|
||||
*/
|
||||
BatchTransportReader acceptInvitationResponse(int code, long timeout);
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package net.sf.briar.api.plugins;
|
||||
|
||||
import net.sf.briar.api.ContactId;
|
||||
import net.sf.briar.api.transport.BatchTransportReader;
|
||||
import net.sf.briar.api.transport.BatchTransportWriter;
|
||||
|
||||
/**
|
||||
* An interface for receiving readers and writers created by a batch-mode
|
||||
* transport plugin.
|
||||
*/
|
||||
public interface BatchPluginCallback extends PluginCallback {
|
||||
|
||||
void readerCreated(BatchTransportReader r);
|
||||
|
||||
void writerCreated(ContactId c, BatchTransportWriter w);
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package net.sf.briar.api.plugins;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
public interface BatchPluginFactory {
|
||||
|
||||
BatchPlugin createPlugin(Executor pluginExecutor,
|
||||
BatchPluginCallback callback);
|
||||
}
|
||||
26
api/net/sf/briar/api/plugins/DuplexPlugin.java
Normal file
26
api/net/sf/briar/api/plugins/DuplexPlugin.java
Normal file
@@ -0,0 +1,26 @@
|
||||
package net.sf.briar.api.plugins;
|
||||
|
||||
import net.sf.briar.api.ContactId;
|
||||
|
||||
/** An interface for transport plugins that support duplex communication. */
|
||||
public interface DuplexPlugin extends Plugin {
|
||||
|
||||
/**
|
||||
* Attempts to create and return a connection to the given contact using
|
||||
* the current transport and configuration properties. Returns null if a
|
||||
* connection could not be created.
|
||||
*/
|
||||
DuplexTransportConnection createConnection(ContactId c);
|
||||
|
||||
/**
|
||||
* Starts the invitation process from the inviter's side. Returns null if
|
||||
* no connection can be established within the given timeout.
|
||||
*/
|
||||
DuplexTransportConnection sendInvitation(int code, long timeout);
|
||||
|
||||
/**
|
||||
* Starts the invitation process from the invitee's side. Returns null if
|
||||
* no connection can be established within the given timeout.
|
||||
*/
|
||||
DuplexTransportConnection acceptInvitation(int code, long timeout);
|
||||
}
|
||||
13
api/net/sf/briar/api/plugins/DuplexPluginCallback.java
Normal file
13
api/net/sf/briar/api/plugins/DuplexPluginCallback.java
Normal file
@@ -0,0 +1,13 @@
|
||||
package net.sf.briar.api.plugins;
|
||||
|
||||
import net.sf.briar.api.ContactId;
|
||||
|
||||
/**
|
||||
* An interface for receiving connections created by a duplex transport plugin.
|
||||
*/
|
||||
public interface DuplexPluginCallback extends PluginCallback {
|
||||
|
||||
void incomingConnectionCreated(DuplexTransportConnection d);
|
||||
|
||||
void outgoingConnectionCreated(ContactId c, DuplexTransportConnection d);
|
||||
}
|
||||
9
api/net/sf/briar/api/plugins/DuplexPluginFactory.java
Normal file
9
api/net/sf/briar/api/plugins/DuplexPluginFactory.java
Normal file
@@ -0,0 +1,9 @@
|
||||
package net.sf.briar.api.plugins;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
public interface DuplexPluginFactory {
|
||||
|
||||
DuplexPlugin createPlugin(Executor pluginExecutor,
|
||||
DuplexPluginCallback callback);
|
||||
}
|
||||
@@ -1,15 +1,15 @@
|
||||
package net.sf.briar.api.transport;
|
||||
package net.sf.briar.api.plugins;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
/**
|
||||
* An interface for reading and writing data over a stream-mode transport. The
|
||||
* An interface for reading and writing data over a duplex transport. The
|
||||
* connection is not responsible for encrypting/decrypting or authenticating
|
||||
* the data.
|
||||
*/
|
||||
public interface StreamTransportConnection {
|
||||
public interface DuplexTransportConnection {
|
||||
|
||||
/** Returns an input stream for reading from the connection. */
|
||||
InputStream getInputStream() throws IOException;
|
||||
45
api/net/sf/briar/api/plugins/SimplexPlugin.java
Normal file
45
api/net/sf/briar/api/plugins/SimplexPlugin.java
Normal file
@@ -0,0 +1,45 @@
|
||||
package net.sf.briar.api.plugins;
|
||||
|
||||
import net.sf.briar.api.ContactId;
|
||||
|
||||
/** An interface for transport plugins that support simplex communication. */
|
||||
public interface SimplexPlugin extends Plugin {
|
||||
|
||||
/**
|
||||
* Attempts to create and return a reader for the given contact using the
|
||||
* current transport and configuration properties. Returns null if a reader
|
||||
* could not be created.
|
||||
*/
|
||||
SimplexTransportReader createReader(ContactId c);
|
||||
|
||||
/**
|
||||
* Attempts to create and return a writer for the given contact using the
|
||||
* current transport and configuration properties. Returns null if a writer
|
||||
* could not be created.
|
||||
*/
|
||||
SimplexTransportWriter createWriter(ContactId c);
|
||||
|
||||
/**
|
||||
* Starts the invitation process from the inviter's side. Returns null if
|
||||
* no connection can be established within the given timeout.
|
||||
*/
|
||||
SimplexTransportWriter sendInvitation(int code, long timeout);
|
||||
|
||||
/**
|
||||
* Starts the invitation process from the invitee's side. Returns null if
|
||||
* no connection can be established within the given timeout.
|
||||
*/
|
||||
SimplexTransportReader acceptInvitation(int code, long timeout);
|
||||
|
||||
/**
|
||||
* Continues the invitation process from the invitee's side. Returns null
|
||||
* if no connection can be established within the given timeout.
|
||||
*/
|
||||
SimplexTransportWriter sendInvitationResponse(int code, long timeout);
|
||||
|
||||
/**
|
||||
* Continues the invitation process from the inviter's side. Returns null
|
||||
* if no connection can be established within the given timeout.
|
||||
*/
|
||||
SimplexTransportReader acceptInvitationResponse(int code, long timeout);
|
||||
}
|
||||
13
api/net/sf/briar/api/plugins/SimplexPluginCallback.java
Normal file
13
api/net/sf/briar/api/plugins/SimplexPluginCallback.java
Normal file
@@ -0,0 +1,13 @@
|
||||
package net.sf.briar.api.plugins;
|
||||
|
||||
import net.sf.briar.api.ContactId;
|
||||
|
||||
/**
|
||||
* An interface for receiving readers and writers created by a simplex plugin.
|
||||
*/
|
||||
public interface SimplexPluginCallback extends PluginCallback {
|
||||
|
||||
void readerCreated(SimplexTransportReader r);
|
||||
|
||||
void writerCreated(ContactId c, SimplexTransportWriter w);
|
||||
}
|
||||
9
api/net/sf/briar/api/plugins/SimplexPluginFactory.java
Normal file
9
api/net/sf/briar/api/plugins/SimplexPluginFactory.java
Normal file
@@ -0,0 +1,9 @@
|
||||
package net.sf.briar.api.plugins;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
public interface SimplexPluginFactory {
|
||||
|
||||
SimplexPlugin createPlugin(Executor pluginExecutor,
|
||||
SimplexPluginCallback callback);
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
package net.sf.briar.api.transport;
|
||||
package net.sf.briar.api.plugins;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* An interface for reading data from a batch-mode transport. The reader is not
|
||||
* An interface for reading data from a simplex transport. The reader is not
|
||||
* responsible for decrypting or authenticating the data before returning it.
|
||||
*/
|
||||
public interface BatchTransportReader {
|
||||
public interface SimplexTransportReader {
|
||||
|
||||
/** Returns an input stream for reading from the transport. */
|
||||
InputStream getInputStream();
|
||||
@@ -1,12 +1,12 @@
|
||||
package net.sf.briar.api.transport;
|
||||
package net.sf.briar.api.plugins;
|
||||
|
||||
import java.io.OutputStream;
|
||||
|
||||
/**
|
||||
* An interface for writing data to a batch-mode transport. The writer is not
|
||||
* An interface for writing data to a simplex transport. The writer is not
|
||||
* responsible for authenticating or encrypting the data before writing it.
|
||||
*/
|
||||
public interface BatchTransportWriter {
|
||||
public interface SimplexTransportWriter {
|
||||
|
||||
/** Returns the capacity of the transport in bytes. */
|
||||
long getCapacity();
|
||||
@@ -1,30 +0,0 @@
|
||||
package net.sf.briar.api.plugins;
|
||||
|
||||
import net.sf.briar.api.ContactId;
|
||||
import net.sf.briar.api.transport.StreamTransportConnection;
|
||||
|
||||
/**
|
||||
* An interface for transport plugins that support bidirectional, reliable,
|
||||
* ordered, timely delivery of data.
|
||||
*/
|
||||
public interface StreamPlugin extends Plugin {
|
||||
|
||||
/**
|
||||
* Attempts to create and return a StreamTransportConnection to the given
|
||||
* contact using the current transport and configuration properties.
|
||||
* Returns null if a connection could not be created.
|
||||
*/
|
||||
StreamTransportConnection createConnection(ContactId c);
|
||||
|
||||
/**
|
||||
* Starts the invitation process from the inviter's side. Returns null if
|
||||
* no connection can be established within the given timeout.
|
||||
*/
|
||||
StreamTransportConnection sendInvitation(int code, long timeout);
|
||||
|
||||
/**
|
||||
* Starts the invitation process from the invitee's side. Returns null if
|
||||
* no connection can be established within the given timeout.
|
||||
*/
|
||||
StreamTransportConnection acceptInvitation(int code, long timeout);
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package net.sf.briar.api.plugins;
|
||||
|
||||
import net.sf.briar.api.ContactId;
|
||||
import net.sf.briar.api.transport.StreamTransportConnection;
|
||||
|
||||
/**
|
||||
* An interface for receiving connections created by a stream-mode transport
|
||||
* plugin.
|
||||
*/
|
||||
public interface StreamPluginCallback extends PluginCallback {
|
||||
|
||||
void incomingConnectionCreated(StreamTransportConnection s);
|
||||
|
||||
void outgoingConnectionCreated(ContactId c, StreamTransportConnection s);
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package net.sf.briar.api.plugins;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
public interface StreamPluginFactory {
|
||||
|
||||
StreamPlugin createPlugin(Executor pluginExecutor,
|
||||
StreamPluginCallback callback);
|
||||
}
|
||||
@@ -1,16 +1,16 @@
|
||||
package net.sf.briar.api.protocol.stream;
|
||||
package net.sf.briar.api.protocol.duplex;
|
||||
|
||||
import net.sf.briar.api.ContactId;
|
||||
import net.sf.briar.api.plugins.DuplexTransportConnection;
|
||||
import net.sf.briar.api.protocol.TransportId;
|
||||
import net.sf.briar.api.protocol.TransportIndex;
|
||||
import net.sf.briar.api.transport.ConnectionContext;
|
||||
import net.sf.briar.api.transport.StreamTransportConnection;
|
||||
|
||||
public interface StreamConnectionFactory {
|
||||
public interface DuplexConnectionFactory {
|
||||
|
||||
void createIncomingConnection(ConnectionContext ctx, TransportId t,
|
||||
StreamTransportConnection s, byte[] tag);
|
||||
DuplexTransportConnection d, byte[] tag);
|
||||
|
||||
void createOutgoingConnection(ContactId c, TransportId t, TransportIndex i,
|
||||
StreamTransportConnection s);
|
||||
DuplexTransportConnection d);
|
||||
}
|
||||
@@ -1,17 +1,17 @@
|
||||
package net.sf.briar.api.protocol.batch;
|
||||
package net.sf.briar.api.protocol.simplex;
|
||||
|
||||
import net.sf.briar.api.ContactId;
|
||||
import net.sf.briar.api.plugins.SimplexTransportReader;
|
||||
import net.sf.briar.api.plugins.SimplexTransportWriter;
|
||||
import net.sf.briar.api.protocol.TransportId;
|
||||
import net.sf.briar.api.protocol.TransportIndex;
|
||||
import net.sf.briar.api.transport.BatchTransportReader;
|
||||
import net.sf.briar.api.transport.BatchTransportWriter;
|
||||
import net.sf.briar.api.transport.ConnectionContext;
|
||||
|
||||
public interface BatchConnectionFactory {
|
||||
public interface SimplexConnectionFactory {
|
||||
|
||||
void createIncomingConnection(ConnectionContext ctx, TransportId t,
|
||||
BatchTransportReader r, byte[] tag);
|
||||
SimplexTransportReader r, byte[] tag);
|
||||
|
||||
void createOutgoingConnection(ContactId c, TransportId t, TransportIndex i,
|
||||
BatchTransportWriter w);
|
||||
SimplexTransportWriter w);
|
||||
}
|
||||
@@ -1,18 +1,21 @@
|
||||
package net.sf.briar.api.transport;
|
||||
|
||||
import net.sf.briar.api.ContactId;
|
||||
import net.sf.briar.api.plugins.SimplexTransportReader;
|
||||
import net.sf.briar.api.plugins.SimplexTransportWriter;
|
||||
import net.sf.briar.api.plugins.DuplexTransportConnection;
|
||||
import net.sf.briar.api.protocol.TransportId;
|
||||
import net.sf.briar.api.protocol.TransportIndex;
|
||||
|
||||
public interface ConnectionDispatcher {
|
||||
|
||||
void dispatchReader(TransportId t, BatchTransportReader r);
|
||||
void dispatchReader(TransportId t, SimplexTransportReader r);
|
||||
|
||||
void dispatchWriter(ContactId c, TransportId t, TransportIndex i,
|
||||
BatchTransportWriter w);
|
||||
SimplexTransportWriter w);
|
||||
|
||||
void dispatchIncomingConnection(TransportId t, StreamTransportConnection s);
|
||||
void dispatchIncomingConnection(TransportId t, DuplexTransportConnection d);
|
||||
|
||||
void dispatchOutgoingConnection(ContactId c, TransportId t,
|
||||
TransportIndex i, StreamTransportConnection s);
|
||||
TransportIndex i, DuplexTransportConnection d);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user