/** * Shorthand for {@link #startEventStream(EventsThreadListener, NetworkConnectivityReceiver, String)} with no eventListener * using a DataHandler and no specific failure callback. * * @param initialToken the initial sync token (null to sync from scratch). */ public void startEventStream(String initialToken) { checkIfAlive(); startEventStream(null, mNetworkConnectivityReceiver, initialToken); }
@Override public void onStoreReady(String s) { session.getDataHandler().checkPermanentStorageData(); session.startEventStream(store.getEventStreamToken()); session.getDataHandler().addListener(evLis); }
/** * This methods init the event stream and check for initial sync * * @param session the session to sync * @param withCrypto true if crypto is enabled and should be checked */ public void syncSession(@Nonnull final MXSession session, final boolean withCrypto) throws InterruptedException { final Map<String, Boolean> params = new HashMap<>(); final int sizeOfLock = withCrypto ? 2 : 1; final CountDownLatch lock2 = new CountDownLatch(sizeOfLock); session.getDataHandler().addListener(new MXEventListener() { @Override public void onInitialSyncComplete(String toToken) { params.put("isInit", true); lock2.countDown(); } @Override public void onCryptoSyncComplete() { params.put("onCryptoSyncComplete", true); lock2.countDown(); } }); session.getDataHandler().getStore().open(); session.startEventStream(null); await(lock2); Assert.assertTrue(params.containsKey("isInit")); if (withCrypto) { Assert.assertTrue(params.containsKey("onCryptoSyncComplete")); } }
session.startEventStream(store.getEventStreamToken()); session.getDataHandler().addListener(evLis); } else {
bobSession2.startEventStream(null);
bobSession2.startEventStream(null);
bobSession2.startEventStream(null); mTestHelper.await(lock2); Assert.assertTrue(results.containsKey("onInitialSyncComplete"));
aliceSession2.startEventStream(null); mTestHelper.await(lock1b); Assert.assertTrue(results.containsKey("onInitialSyncComplete"));
bobSession2.startEventStream(null); mTestHelper.await(lock4b); Assert.assertTrue(results.containsKey("onInitialSyncComplete"));
aliceSession2.startEventStream(null);
aliceSession2.startEventStream(null);