Files
briar/briar-api/src/org/briarproject/api/ProtocolEngine.java
Torsten Grote 11e6d64e4d Show relevant decline responses in the conversation
* If the user has already declined, we don't show that the other
  introducee has declined as well. The backend doesn't have that information, so
  this is compatible with the principle of showing what we know.
* If the user has already accepted or hasn't yet responded, we show the
  decline response in the private conversation with the introducer. If
  the user hasn't yet responded, we hide the accept/decline buttons
  in the introduction request message.

Messages an introducee receives in a `FINISHED` state are now being
ignored and deleted.

Closes #295
2016-04-21 11:08:15 -03:00

43 lines
1.4 KiB
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 deleteMessage;
public final boolean deleteState;
public final S localState;
public final List<M> toSend;
public final List<Event> toBroadcast;
/**
* This class represents an update of the local protocol state.
* It only shows how the state should be updated,
* but does not carry out the updates on its own.
*
* @param deleteMessage whether to delete the message that triggered the state update. This will be ignored for {@link ProtocolEngine#onLocalAction}.
* @param deleteState whether to delete the localState {@link S}
* @param localState the new local state
* @param toSend a list of messages to be sent as part of the state update
* @param toBroadcast a list of events to broadcast as result of the state update
*/
public StateUpdate(boolean deleteMessage, boolean deleteState,
S localState, List<M> toSend, List<Event> toBroadcast) {
this.deleteMessage = deleteMessage;
this.deleteState = deleteState;
this.localState = localState;
this.toSend = toSend;
this.toBroadcast = toBroadcast;
}
}
}