mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 10:49:06 +01:00
Added a connection registry to avoid creating redundant connections.
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
package net.sf.briar.api.plugins;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
|
||||
import net.sf.briar.api.ContactId;
|
||||
import net.sf.briar.api.protocol.TransportId;
|
||||
|
||||
public interface Plugin {
|
||||
@@ -28,10 +30,11 @@ public interface Plugin {
|
||||
long getPollingInterval();
|
||||
|
||||
/**
|
||||
* Attempts to establish connections to all contacts, passing any created
|
||||
* connections to the callback.
|
||||
* Attempts to establish connections to contacts, passing any created
|
||||
* connections to the callback. To avoid creating redundant connections,
|
||||
* the plugin may exclude the given contacts from polling.
|
||||
*/
|
||||
void poll();
|
||||
void poll(Collection<ContactId> connected);
|
||||
|
||||
/** Returns true if the plugin supports exchanging invitations. */
|
||||
boolean supportsInvitations();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package net.sf.briar.api.protocol.batch;
|
||||
|
||||
import net.sf.briar.api.ContactId;
|
||||
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;
|
||||
@@ -8,9 +9,9 @@ import net.sf.briar.api.transport.ConnectionContext;
|
||||
|
||||
public interface BatchConnectionFactory {
|
||||
|
||||
void createIncomingConnection(ConnectionContext ctx,
|
||||
void createIncomingConnection(ConnectionContext ctx, TransportId t,
|
||||
BatchTransportReader r, byte[] tag);
|
||||
|
||||
void createOutgoingConnection(ContactId c, TransportIndex i,
|
||||
void createOutgoingConnection(ContactId c, TransportId t, TransportIndex i,
|
||||
BatchTransportWriter w);
|
||||
}
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
package net.sf.briar.api.protocol.stream;
|
||||
|
||||
import net.sf.briar.api.ContactId;
|
||||
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 {
|
||||
|
||||
void createIncomingConnection(ConnectionContext ctx,
|
||||
void createIncomingConnection(ConnectionContext ctx, TransportId t,
|
||||
StreamTransportConnection s, byte[] tag);
|
||||
|
||||
void createOutgoingConnection(ContactId c, TransportIndex i,
|
||||
void createOutgoingConnection(ContactId c, TransportId t, TransportIndex i,
|
||||
StreamTransportConnection s);
|
||||
}
|
||||
|
||||
@@ -8,10 +8,11 @@ public interface ConnectionDispatcher {
|
||||
|
||||
void dispatchReader(TransportId t, BatchTransportReader r);
|
||||
|
||||
void dispatchWriter(ContactId c, TransportIndex i, BatchTransportWriter w);
|
||||
void dispatchWriter(ContactId c, TransportId t, TransportIndex i,
|
||||
BatchTransportWriter w);
|
||||
|
||||
void dispatchIncomingConnection(TransportId t, StreamTransportConnection s);
|
||||
|
||||
void dispatchOutgoingConnection(ContactId c, TransportIndex i,
|
||||
StreamTransportConnection s);
|
||||
void dispatchOutgoingConnection(ContactId c, TransportId t,
|
||||
TransportIndex i, StreamTransportConnection s);
|
||||
}
|
||||
|
||||
18
api/net/sf/briar/api/transport/ConnectionRegistry.java
Normal file
18
api/net/sf/briar/api/transport/ConnectionRegistry.java
Normal file
@@ -0,0 +1,18 @@
|
||||
package net.sf.briar.api.transport;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import net.sf.briar.api.ContactId;
|
||||
import net.sf.briar.api.protocol.TransportId;
|
||||
|
||||
/**
|
||||
* Keeps track of which contacts are currently connected by which transports.
|
||||
*/
|
||||
public interface ConnectionRegistry {
|
||||
|
||||
void registerConnection(ContactId c, TransportId t);
|
||||
|
||||
void unregisterConnection(ContactId c, TransportId t);
|
||||
|
||||
Collection<ContactId> getConnectedContacts(TransportId t);
|
||||
}
|
||||
Reference in New Issue
Block a user