mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 19:29:06 +01:00
APIs for segmented transports.
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
package net.sf.briar.api.plugins;
|
||||
package net.sf.briar.api.plugins.duplex;
|
||||
|
||||
import net.sf.briar.api.ContactId;
|
||||
import net.sf.briar.api.plugins.Plugin;
|
||||
|
||||
/** An interface for transport plugins that support duplex communication. */
|
||||
/** An interface for transport plugins that support duplex communication. */
|
||||
public interface DuplexPlugin extends Plugin {
|
||||
|
||||
/**
|
||||
@@ -1,9 +1,10 @@
|
||||
package net.sf.briar.api.plugins;
|
||||
package net.sf.briar.api.plugins.duplex;
|
||||
|
||||
import net.sf.briar.api.ContactId;
|
||||
import net.sf.briar.api.plugins.PluginCallback;
|
||||
|
||||
/**
|
||||
* An interface for receiving connections created by a duplex transport plugin.
|
||||
* An interface for handling connections created by a duplex transport plugin.
|
||||
*/
|
||||
public interface DuplexPluginCallback extends PluginCallback {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package net.sf.briar.api.plugins;
|
||||
package net.sf.briar.api.plugins.duplex;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package net.sf.briar.api.plugins.duplex;
|
||||
|
||||
import net.sf.briar.api.ContactId;
|
||||
|
||||
/**
|
||||
* An interface for transport plugins that support duplex segmented
|
||||
* communication.
|
||||
*/
|
||||
public interface DuplexSegmentedPlugin {
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
DuplexSegmentedTransportConnection createConnection(ContactId c);
|
||||
|
||||
/**
|
||||
* Starts the invitation process from the inviter's side. Returns null if
|
||||
* no connection can be established within the given timeout.
|
||||
*/
|
||||
DuplexSegmentedTransportConnection 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.
|
||||
*/
|
||||
DuplexSegmentedTransportConnection acceptInvitation(int code, long timeout);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package net.sf.briar.api.plugins.duplex;
|
||||
|
||||
import net.sf.briar.api.ContactId;
|
||||
|
||||
/**
|
||||
* An interface for handling connections created by a duplex segmented
|
||||
* transport plugin.
|
||||
*/
|
||||
public interface DuplexSegmentedPluginCallback {
|
||||
|
||||
void incomingConnectionCreated(DuplexSegmentedTransportConnection d);
|
||||
|
||||
void outgoingConnectionCreated(ContactId c,
|
||||
DuplexSegmentedTransportConnection d);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package net.sf.briar.api.plugins.duplex;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
public interface DuplexSegmentedPluginFactory {
|
||||
|
||||
DuplexSegmentedPlugin createPlugin(Executor pluginExecutor,
|
||||
DuplexSegmentedPluginCallback callback);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package net.sf.briar.api.plugins.duplex;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* An interface for reading and writing data over a duplex segmented transport.
|
||||
* The connection is not responsible for encrypting/decrypting or authenticating
|
||||
* the data.
|
||||
*/
|
||||
public interface DuplexSegmentedTransportConnection {
|
||||
|
||||
/**
|
||||
* Reads a frame into the given buffer and returns its length, or -1 if no
|
||||
* more frames can be read.
|
||||
*/
|
||||
int readFrame(byte[] b) throws IOException;
|
||||
|
||||
/** Writes the given frame to the transport. */
|
||||
void writeFrame(byte[] b, int len) throws IOException;
|
||||
|
||||
/**
|
||||
* Returns true if the output stream should be flushed after each packet.
|
||||
*/
|
||||
boolean shouldFlush();
|
||||
|
||||
/**
|
||||
* Closes the connection and disposes of any associated resources. The
|
||||
* first argument indicates whether the connection is being closed because
|
||||
* of an exception and the second argument indicates whether the connection
|
||||
* was recognised, which may affect how resources are disposed of.
|
||||
*/
|
||||
void dispose(boolean exception, boolean recognised);
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package net.sf.briar.api.plugins;
|
||||
package net.sf.briar.api.plugins.duplex;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@@ -1,6 +1,7 @@
|
||||
package net.sf.briar.api.plugins;
|
||||
package net.sf.briar.api.plugins.simplex;
|
||||
|
||||
import net.sf.briar.api.ContactId;
|
||||
import net.sf.briar.api.plugins.Plugin;
|
||||
|
||||
/** An interface for transport plugins that support simplex communication. */
|
||||
public interface SimplexPlugin extends Plugin {
|
||||
@@ -1,9 +1,11 @@
|
||||
package net.sf.briar.api.plugins;
|
||||
package net.sf.briar.api.plugins.simplex;
|
||||
|
||||
import net.sf.briar.api.ContactId;
|
||||
import net.sf.briar.api.plugins.PluginCallback;
|
||||
|
||||
/**
|
||||
* An interface for receiving readers and writers created by a simplex plugin.
|
||||
* An interface for handling readers and writers created by a simplex transport
|
||||
* plugin.
|
||||
*/
|
||||
public interface SimplexPluginCallback extends PluginCallback {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package net.sf.briar.api.plugins;
|
||||
package net.sf.briar.api.plugins.simplex;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package net.sf.briar.api.plugins.simplex;
|
||||
|
||||
import net.sf.briar.api.ContactId;
|
||||
|
||||
/**
|
||||
* An interface for transport plugins that support simplex segmented
|
||||
* communication.
|
||||
*/
|
||||
public interface SimplexSegmentedPlugin {
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
SimplexSegmentedTransportReader 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.
|
||||
*/
|
||||
SimplexSegmentedTransportWriter createWriter(ContactId c);
|
||||
|
||||
/**
|
||||
* Starts the invitation process from the inviter's side. Returns null if
|
||||
* no connection can be established within the given timeout.
|
||||
*/
|
||||
SimplexSegmentedTransportWriter 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.
|
||||
*/
|
||||
SimplexSegmentedTransportReader 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.
|
||||
*/
|
||||
SimplexSegmentedTransportWriter 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.
|
||||
*/
|
||||
SimplexSegmentedTransportReader acceptInvitationResponse(int code,
|
||||
long timeout);
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package net.sf.briar.api.plugins.simplex;
|
||||
|
||||
import net.sf.briar.api.ContactId;
|
||||
|
||||
/**
|
||||
* An interface for handling readers and writers created by a simplex
|
||||
* segmented transport plugin.
|
||||
*/
|
||||
public interface SimplexSegmentedPluginCallback {
|
||||
|
||||
void readerCreated(SimplexSegmentedTransportReader r);
|
||||
|
||||
void writerCreated(ContactId c, SimplexSegmentedTransportWriter w);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package net.sf.briar.api.plugins.simplex;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
public interface SimplexSegmentedPluginFactory {
|
||||
|
||||
SimplexSegmentedPlugin createPlugin(Executor pluginExecutor,
|
||||
SimplexSegmentedPluginCallback callback);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package net.sf.briar.api.plugins.simplex;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* An interface for reading data from a simplex segmented transport. The reader
|
||||
* is not responsible for decrypting or authenticating the data before
|
||||
* returning it.
|
||||
*/
|
||||
public interface SimplexSegmentedTransportReader {
|
||||
|
||||
/**
|
||||
* Reads a frame into the given buffer and returns its length, or -1 if no
|
||||
* more frames can be read.
|
||||
*/
|
||||
int readFrame(byte[] b) throws IOException;
|
||||
|
||||
/**
|
||||
* Closes the reader and disposes of any associated resources. The first
|
||||
* argument indicates whether the reader is being closed because of an
|
||||
* exception and the second argument indicates whether the connection was
|
||||
* recognised, which may affect how resources are disposed of.
|
||||
*/
|
||||
void dispose(boolean exception, boolean recognised);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package net.sf.briar.api.plugins.simplex;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* An interface for writing data to a simplex segmented transport. The writer is
|
||||
* not responsible for authenticating or encrypting the data before writing it.
|
||||
*/
|
||||
public interface SimplexSegmentedTransportWriter {
|
||||
|
||||
/** Returns the capacity of the transport in bytes. */
|
||||
long getCapacity();
|
||||
|
||||
/** Writes the given frame to the transport. */
|
||||
void writeFrame(byte[] b, int len) throws IOException;
|
||||
|
||||
/**
|
||||
* Returns true if the output stream should be flushed after each packet.
|
||||
*/
|
||||
boolean shouldFlush();
|
||||
|
||||
/**
|
||||
* Closes the writer and disposes of any associated resources. The
|
||||
* argument indicates whether the writer is being closed because of an
|
||||
* exception, which may affect how resources are disposed of.
|
||||
*/
|
||||
void dispose(boolean exception);
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package net.sf.briar.api.plugins;
|
||||
package net.sf.briar.api.plugins.simplex;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package net.sf.briar.api.plugins;
|
||||
package net.sf.briar.api.plugins.simplex;
|
||||
|
||||
import java.io.OutputStream;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
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.plugins.duplex.DuplexTransportConnection;
|
||||
import net.sf.briar.api.protocol.TransportId;
|
||||
import net.sf.briar.api.protocol.TransportIndex;
|
||||
import net.sf.briar.api.transport.ConnectionContext;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
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.plugins.simplex.SimplexTransportReader;
|
||||
import net.sf.briar.api.plugins.simplex.SimplexTransportWriter;
|
||||
import net.sf.briar.api.protocol.TransportId;
|
||||
import net.sf.briar.api.protocol.TransportIndex;
|
||||
import net.sf.briar.api.transport.ConnectionContext;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
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.plugins.duplex.DuplexTransportConnection;
|
||||
import net.sf.briar.api.plugins.simplex.SimplexTransportReader;
|
||||
import net.sf.briar.api.plugins.simplex.SimplexTransportWriter;
|
||||
import net.sf.briar.api.protocol.TransportId;
|
||||
import net.sf.briar.api.protocol.TransportIndex;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user