syncbase/src/main/java/io/v/syncbase/Syncbase.java
/**
     * Scans the neighborhood for nearby users.
     *
     * @param cb The callback to call when a User is found or lost.
     */
Scans the neighborhood for nearby users.
@param cb The callback to call when a User is found or lost.
Scans the neighborhood for nearby users . @param cb The callback to call when a User is found or lost .
public static void addScanForUsersInNeighborhood(final ScanNeighborhoodForUsersCallback cb) {
        synchronized (sScanMappingMu) {
            try {
                long scanId = Neighborhood.NewScan(new Neighborhood.NeighborhoodScanCallbacks() {
                    @Override
                    public void onPeer(final NeighborhoodPeer peer) {
                        final SettableFuture<Boolean> setFuture = SettableFuture.create();
                        Syncbase.sOpts.mCallbackExecutor.execute(new Runnable() {
                            @Override
                            public void run() {
                                User u = new User(getAliasFromBlessingPattern(peer.blessings));
                                if (peer.isLost) {
                                    cb.onLost(u);
                                } else {
                                    cb.onFound(u);
                                }
                                setFuture.set(true);
                            }
                        });
                        try {
                            setFuture.get();
                        } catch (InterruptedException | ExecutionException e) {
                            e.printStackTrace();
                            System.err.println(e.toString());
                        }
                    }
                });
                sScanMapping.put(cb, scanId);
            } catch (VError vError) {
                cb.onError(vError);
            }
        }
    }
public static void addScanForUsersInNeighborhood ( final ScanNeighborhoodForUsersCallback cb ) { synchronized ( sScanMappingMu ) { try { long scanId = Neighborhood . NewScan ( new Neighborhood . NeighborhoodScanCallbacks ( ) { @ Override public void onPeer ( final NeighborhoodPeer peer ) { final SettableFuture < Boolean > setFuture = SettableFuture . create ( ) ; Syncbase . sOpts . mCallbackExecutor . execute ( new Runnable ( ) { @ Override public void run ( ) { User u = new User ( getAliasFromBlessingPattern ( peer . blessings ) ) ; if ( peer . isLost ) { cb . onLost ( u ) ; } else { cb . onFound ( u ) ; } setFuture . set ( true ) ; } } ) ; try { setFuture . get ( ) ; } catch ( InterruptedException | ExecutionException e ) { e . printStackTrace ( ) ; System . err . println ( e . toString ( ) ) ; } } } ) ; sScanMapping . put ( cb , scanId ) ; } catch ( VError vError ) { cb . onError ( vError ) ; } } }
Scans the neighborhood for nearby users.
Scans the neighborhood for nearby users .