mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 03:09:04 +01:00
Use the event bus to observe contacts connecting and disconnecting.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user