mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 19:29:06 +01:00
Pass a connection handler to plugins when polling.
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
package org.briarproject.bramble.api.plugin;
|
||||
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.bramble.api.plugin.duplex.DuplexTransportConnection;
|
||||
|
||||
/**
|
||||
* An interface for handling connections created by transport plugins.
|
||||
*/
|
||||
@NotNullByDefault
|
||||
public interface ConnectionHandler {
|
||||
|
||||
void handleConnection(DuplexTransportConnection c);
|
||||
|
||||
void handleReader(TransportConnectionReader r);
|
||||
|
||||
void handleWriter(TransportConnectionWriter w);
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
package org.briarproject.bramble.api.plugin;
|
||||
|
||||
import org.briarproject.bramble.api.contact.ContactId;
|
||||
import org.briarproject.bramble.api.Pair;
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.bramble.api.properties.TransportProperties;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
|
||||
@NotNullByDefault
|
||||
public interface Plugin {
|
||||
@@ -51,8 +51,9 @@ public interface Plugin {
|
||||
int getPollingInterval();
|
||||
|
||||
/**
|
||||
* Attempts to establish connections to the given contacts, passing any
|
||||
* created connections to the callback.
|
||||
* Attempts to create connections using the given transport properties,
|
||||
* passing any created connections to the corresponding handlers.
|
||||
*/
|
||||
void poll(Map<ContactId, TransportProperties> contacts);
|
||||
void poll(Collection<Pair<TransportProperties, ConnectionHandler>>
|
||||
properties);
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import org.briarproject.bramble.api.settings.Settings;
|
||||
* the application.
|
||||
*/
|
||||
@NotNullByDefault
|
||||
public interface PluginCallback {
|
||||
public interface PluginCallback extends ConnectionHandler {
|
||||
|
||||
/**
|
||||
* Returns the plugin's settings
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
package org.briarproject.bramble.api.plugin.duplex;
|
||||
|
||||
import org.briarproject.bramble.api.contact.ContactId;
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.bramble.api.plugin.PluginCallback;
|
||||
|
||||
/**
|
||||
* An interface through which a duplex plugin interacts with the rest of the
|
||||
* application.
|
||||
*/
|
||||
@NotNullByDefault
|
||||
public interface DuplexPluginCallback extends PluginCallback {
|
||||
|
||||
void incomingConnectionCreated(DuplexTransportConnection d);
|
||||
|
||||
void outgoingConnectionCreated(ContactId c, DuplexTransportConnection d);
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.briarproject.bramble.api.plugin.duplex;
|
||||
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.bramble.api.plugin.PluginCallback;
|
||||
import org.briarproject.bramble.api.plugin.TransportId;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@@ -25,5 +26,5 @@ public interface DuplexPluginFactory {
|
||||
* Creates and returns a plugin, or null if no plugin can be created.
|
||||
*/
|
||||
@Nullable
|
||||
DuplexPlugin createPlugin(DuplexPluginCallback callback);
|
||||
DuplexPlugin createPlugin(PluginCallback callback);
|
||||
}
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
package org.briarproject.bramble.api.plugin.simplex;
|
||||
|
||||
import org.briarproject.bramble.api.contact.ContactId;
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.bramble.api.plugin.PluginCallback;
|
||||
import org.briarproject.bramble.api.plugin.TransportConnectionReader;
|
||||
import org.briarproject.bramble.api.plugin.TransportConnectionWriter;
|
||||
|
||||
/**
|
||||
* An interface through which a simplex plugin interacts with the rest of the
|
||||
* application.
|
||||
*/
|
||||
@NotNullByDefault
|
||||
public interface SimplexPluginCallback extends PluginCallback {
|
||||
|
||||
void readerCreated(TransportConnectionReader r);
|
||||
|
||||
void writerCreated(ContactId c, TransportConnectionWriter w);
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.briarproject.bramble.api.plugin.simplex;
|
||||
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.bramble.api.plugin.PluginCallback;
|
||||
import org.briarproject.bramble.api.plugin.TransportId;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@@ -25,5 +26,5 @@ public interface SimplexPluginFactory {
|
||||
* Creates and returns a plugin, or null if no plugin can be created.
|
||||
*/
|
||||
@Nullable
|
||||
SimplexPlugin createPlugin(SimplexPluginCallback callback);
|
||||
SimplexPlugin createPlugin(PluginCallback callback);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user