mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 18:59:06 +01:00
Updated transport plugin API.
This commit is contained in:
16
api/net/sf/briar/api/transport/TransportCallback.java
Normal file
16
api/net/sf/briar/api/transport/TransportCallback.java
Normal file
@@ -0,0 +1,16 @@
|
||||
package net.sf.briar.api.transport;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface TransportCallback {
|
||||
|
||||
void setLocalTransports(Map<String, String> transports);
|
||||
|
||||
void setConfig(Map<String, String> config);
|
||||
|
||||
void showMessage(String message);
|
||||
|
||||
boolean showConfirmationMessage(String message);
|
||||
|
||||
int showChoice(String message, String[] choices);
|
||||
}
|
||||
@@ -1,18 +1,14 @@
|
||||
package net.sf.briar.api.transport.batch;
|
||||
|
||||
import java.util.Map;
|
||||
import net.sf.briar.api.transport.TransportCallback;
|
||||
|
||||
/**
|
||||
* An interface for receiving readers and writers created by a batch-mode
|
||||
* transport plugin.
|
||||
*/
|
||||
public interface BatchTransportCallback {
|
||||
public interface BatchTransportCallback extends TransportCallback {
|
||||
|
||||
void readerCreated(BatchTransportReader r);
|
||||
|
||||
void writerCreated(BatchTransportWriter w);
|
||||
|
||||
void setLocalTransports(Map<String, String> transports);
|
||||
|
||||
void setConfig(Map<String, String> config);
|
||||
}
|
||||
|
||||
@@ -16,9 +16,14 @@ public interface BatchTransportWriter {
|
||||
OutputStream getOutputStream();
|
||||
|
||||
/**
|
||||
* Closes the writer and disposes of any associated state. This method must
|
||||
* be called even if the writer is not used, or if an exception is thrown
|
||||
* while using the writer.
|
||||
* Finishes writing to the transport. This method should be called after
|
||||
* flushing and closing the output stream.
|
||||
*/
|
||||
void finish() throws IOException;
|
||||
|
||||
/**
|
||||
* Disposes of any associated state. This method must be called even if the
|
||||
* writer is not used, or if an exception is thrown while using the writer.
|
||||
*/
|
||||
void dispose() throws IOException;
|
||||
}
|
||||
|
||||
@@ -1,16 +1,12 @@
|
||||
package net.sf.briar.api.transport.stream;
|
||||
|
||||
import java.util.Map;
|
||||
import net.sf.briar.api.transport.TransportCallback;
|
||||
|
||||
/**
|
||||
* An interface for receiving connections created by a stream-mode transport
|
||||
* plugin.
|
||||
*/
|
||||
public interface StreamTransportCallback {
|
||||
public interface StreamTransportCallback extends TransportCallback {
|
||||
|
||||
void connectionCreated(StreamTransportConnection c);
|
||||
|
||||
void setLocalTransports(Map<String, String> transports);
|
||||
|
||||
void setConfig(Map<String, String> config);
|
||||
}
|
||||
|
||||
@@ -23,6 +23,10 @@ class TestBatchTransportWriter implements BatchTransportWriter {
|
||||
return out;
|
||||
}
|
||||
|
||||
public void finish() throws IOException {
|
||||
// Nothing to do
|
||||
}
|
||||
|
||||
public void dispose() throws IOException {
|
||||
// The output stream may have been left open
|
||||
out.close();
|
||||
|
||||
Reference in New Issue
Block a user