@Test public void testOnLeaveMessageFromAwaitMember() throws Exception { PeerSession session = getDefaultSession(AWAIT_MEMBER); assertNotNull(leaveMessage.getPreviousMessageId()); assertNotNull(session.getLastRemoteMessageId()); assertTrue(leaveMessage.getPreviousMessageId() .equals(session.getLastRemoteMessageId())); PeerSession newSession = engine.onLeaveMessage(txn, session, leaveMessage); assertEquals(START, newSession.getState()); assertEquals(session.getLastLocalMessageId(), newSession.getLastLocalMessageId()); assertEquals(leaveMessage.getId(), newSession.getLastRemoteMessageId()); assertEquals(session.getLocalTimestamp(), newSession.getLocalTimestamp()); assertSessionConstantsUnchanged(session, newSession); }
@Override public PeerSession onLeaveMessage(Transaction txn, PeerSession s, LeaveMessage m) throws DbException, FormatException { switch (s.getState()) { case START: case NEITHER_JOINED: case LOCAL_JOINED: return abort(txn, s); case AWAIT_MEMBER: return onRemoteLeaveFromAwaitMember(txn, s, m); case LOCAL_LEFT: return onRemoteLeaveFromLocalLeft(txn, s, m); case BOTH_JOINED: return onRemoteLeaveFromBothJoined(txn, s, m); case ERROR: return s; default: throw new AssertionError(); } }
PeerProtocolEngine extends AbstractProtocolEngine<PeerSession> { @Override public PeerSession onLeaveMessage(Transaction txn, PeerSession s, LeaveMessage m) throws DbException, FormatException { switch (s.getState()) { case START: case NEITHER_JOINED: case LOCAL_JOINED: return abort(txn, s); case AWAIT_MEMBER: return onRemoteLeaveFromAwaitMember(txn, s, m); case LOCAL_LEFT: return onRemoteLeaveFromLocalLeft(txn, s, m); case BOTH_JOINED: return onRemoteLeaveFromBothJoined(txn, s, m); case ERROR: return s; default: throw new AssertionError(); } } }
PeerProtocolEngine extends AbstractProtocolEngine<PeerSession> { @Override public PeerSession onLeaveMessage(Transaction txn, PeerSession s, LeaveMessage m) throws DbException, FormatException { switch (s.getState()) { case START: case NEITHER_JOINED: case LOCAL_JOINED: return abort(txn, s); case AWAIT_MEMBER: return onRemoteLeaveFromAwaitMember(txn, s, m); case LOCAL_LEFT: return onRemoteLeaveFromLocalLeft(txn, s, m); case BOTH_JOINED: return onRemoteLeaveFromBothJoined(txn, s, m); case ERROR: return s; default: throw new AssertionError(); } } PeerProtocolEngine(DatabaseComponent db, ClientHelper clientHelper,
			ClientVersioningManager clientVersioningManager,
			PrivateGroupManager privateGroupManager,
			PrivateGroupFactory privateGroupFactory,
			GroupMessageFactory groupMessageFactory,
			IdentityManager identityManager, MessageParser messageParser,
			MessageEncoder messageEncoder, MessageTracker messageTracker,
			Clock clock); }
PeerProtocolEngine extends AbstractProtocolEngine<PeerSession> { @Override public PeerSession onLeaveMessage(Transaction txn, PeerSession s, LeaveMessage m) throws DbException, FormatException { switch (s.getState()) { case START: case NEITHER_JOINED: case LOCAL_JOINED: return abort(txn, s); case AWAIT_MEMBER: return onRemoteLeaveFromAwaitMember(txn, s, m); case LOCAL_LEFT: return onRemoteLeaveFromLocalLeft(txn, s, m); case BOTH_JOINED: return onRemoteLeaveFromBothJoined(txn, s, m); case ERROR: return s; default: throw new AssertionError(); } } PeerProtocolEngine(DatabaseComponent db, ClientHelper clientHelper,
			ClientVersioningManager clientVersioningManager,
			PrivateGroupManager privateGroupManager,
			PrivateGroupFactory privateGroupFactory,
			GroupMessageFactory groupMessageFactory,
			IdentityManager identityManager, MessageParser messageParser,
			MessageEncoder messageEncoder, MessageTracker messageTracker,
			Clock clock); @Override PeerSession onInviteAction(Transaction txn, PeerSession s,
			@Nullable String message, long timestamp, byte[] signature); @Override PeerSession onJoinAction(Transaction txn, PeerSession s); @Override PeerSession onLeaveAction(Transaction txn, PeerSession s); @Override PeerSession onMemberAddedAction(Transaction txn, PeerSession s); @Override PeerSession onInviteMessage(Transaction txn, PeerSession s,
			InviteMessage m); @Override PeerSession onJoinMessage(Transaction txn, PeerSession s,
			JoinMessage m); @Override PeerSession onLeaveMessage(Transaction txn, PeerSession s,
			LeaveMessage m); @Override PeerSession onAbortMessage(Transaction txn, PeerSession s,
			AbortMessage m); }
PeerProtocolEngine extends AbstractProtocolEngine<PeerSession> { @Override public PeerSession onLeaveMessage(Transaction txn, PeerSession s, LeaveMessage m) throws DbException, FormatException { switch (s.getState()) { case START: case NEITHER_JOINED: case LOCAL_JOINED: return abort(txn, s); case AWAIT_MEMBER: return onRemoteLeaveFromAwaitMember(txn, s, m); case LOCAL_LEFT: return onRemoteLeaveFromLocalLeft(txn, s, m); case BOTH_JOINED: return onRemoteLeaveFromBothJoined(txn, s, m); case ERROR: return s; default: throw new AssertionError(); } } PeerProtocolEngine(DatabaseComponent db, ClientHelper clientHelper,
			ClientVersioningManager clientVersioningManager,
			PrivateGroupManager privateGroupManager,
			PrivateGroupFactory privateGroupFactory,
			GroupMessageFactory groupMessageFactory,
			IdentityManager identityManager, MessageParser messageParser,
			MessageEncoder messageEncoder, MessageTracker messageTracker,
			Clock clock); @Override PeerSession onInviteAction(Transaction txn, PeerSession s,
			@Nullable String message, long timestamp, byte[] signature); @Override PeerSession onJoinAction(Transaction txn, PeerSession s); @Override PeerSession onLeaveAction(Transaction txn, PeerSession s); @Override PeerSession onMemberAddedAction(Transaction txn, PeerSession s); @Override PeerSession onInviteMessage(Transaction txn, PeerSession s,
			InviteMessage m); @Override PeerSession onJoinMessage(Transaction txn, PeerSession s,
			JoinMessage m); @Override PeerSession onLeaveMessage(Transaction txn, PeerSession s,
			LeaveMessage m); @Override PeerSession onAbortMessage(Transaction txn, PeerSession s,
			AbortMessage m);  }