Use the event bus to observe contacts connecting and disconnecting.

This commit is contained in:
akwizgran
2014-10-03 10:04:02 +01:00
parent 8b8df435a5
commit cdb5a12156
8 changed files with 85 additions and 51 deletions

View File

@@ -0,0 +1,20 @@
package org.briarproject.api.event;
import org.briarproject.api.ContactId;
/**
* An event that is broadcast when a contact connects that was not previously
* connected via any transport.
*/
public class ContactConnectedEvent extends Event {
private final ContactId contactId;
public ContactConnectedEvent(ContactId contactId) {
this.contactId = contactId;
}
public ContactId getContactId() {
return contactId;
}
}

View File

@@ -0,0 +1,20 @@
package org.briarproject.api.event;
import org.briarproject.api.ContactId;
/**
* An event that is broadcast when a contact disconnects and is no longer
* connected via any transport.
*/
public class ContactDisconnectedEvent extends Event {
private final ContactId contactId;
public ContactDisconnectedEvent(ContactId contactId) {
this.contactId = contactId;
}
public ContactId getContactId() {
return contactId;
}
}

View File

@@ -1,13 +0,0 @@
package org.briarproject.api.transport;
import org.briarproject.api.ContactId;
/** An interface for listening for connection and disconnection events. */
public interface ConnectionListener {
/** Called when a contact connects and has no existing connections. */
void contactConnected(ContactId c);
/** Called when a contact disconnects and has no remaining connections. */
void contactDisconnected(ContactId c);
}

View File

@@ -10,10 +10,6 @@ import org.briarproject.api.TransportId;
*/
public interface ConnectionRegistry {
void addListener(ConnectionListener c);
void removeListener(ConnectionListener c);
void registerConnection(ContactId c, TransportId t);
void unregisterConnection(ContactId c, TransportId t);