mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 18:59:06 +01:00
This Introduction BSP Client uses its own group to communicate with existing contacts. It uses four types of messages to facilitate introductions: the introduction, the response, the ack and the abort. The protocol logic is encapsulated in two protocol engines, one for the introducer and one for the introducee. The introduction client keeps the local state for each engine, hands messages over to the engines and processes the result and state changes they return.
32 lines
840 B
Java
32 lines
840 B
Java
package org.briarproject.api;
|
|
|
|
import org.briarproject.api.event.Event;
|
|
|
|
import java.util.List;
|
|
|
|
public interface ProtocolEngine<A, S, M> {
|
|
StateUpdate<S, M> onLocalAction(S localState, A action);
|
|
|
|
StateUpdate<S, M> onMessageReceived(S localState, M received);
|
|
|
|
StateUpdate<S, M> onMessageDelivered(S localState, M delivered);
|
|
|
|
class StateUpdate<S, M> {
|
|
public final boolean deleteMessages;
|
|
public final boolean deleteState;
|
|
public final S localState;
|
|
public final List<M> toSend;
|
|
public final List<Event> toBroadcast;
|
|
|
|
public StateUpdate(boolean deleteMessages, boolean deleteState,
|
|
S localState, List<M> toSend, List<Event> toBroadcast) {
|
|
|
|
this.deleteMessages = deleteMessages;
|
|
this.deleteState = deleteState;
|
|
this.localState = localState;
|
|
this.toSend = toSend;
|
|
this.toBroadcast = toBroadcast;
|
|
}
|
|
}
|
|
}
|