*pessoal consegui fazer o aplicativo ficar ouvinte mais como faço para fazer a 
sincronia de dados depois disso? preciso dar um push na porta ouvinte*


try {
    manager = new Manager(new AndroidContext(getApplicationContext()), 
Manager.DEFAULT_OPTIONS);
} catch (IOException e) {
    e.printStackTrace();
}
database = DatabaseHelper.getEmptyDatabase("bancsdqs32", manager);
startListener();
startObserveDatabaseChange();

URL url = null;
try {
    url = new URL("http", getLocalIpAddress(), listener.getListenPort(), 
"/bancsdqs32");
} catch (MalformedURLException e) {
    e.printStackTrace();
}

System.out.println("Listening on :: " + listener.getListenPort() + " " + 
url.toString());




public String getLocalIpAddress() {
    WifiManager wm = (WifiManager) 
getApplicationContext().getSystemService(WIFI_SERVICE);
    return Formatter.formatIpAddress(wm.getConnectionInfo().getIpAddress());
}

void startObserveDatabaseChange() {
    try {
        database.addChangeListener(new Database.ChangeListener() {
            @Override
            public void changed(Database.ChangeEvent event) {
                List<DocumentChange> changes = event.getChanges();
                System.out.println("erroooo" +
                        changes);

                for (DocumentChange change : changes) {
                    System.out.println("erroooo " + change.getDocumentId());

                }
            }
        });
    } catch (Exception e) {
        System.out.println("erro" + e);
    }
}

void startListener() {
    listener = new LiteListener(manager, 5432, null);
    Thread thread = new Thread(listener);
    thread.start();
}

-- 
You received this message because you are subscribed to the Google Groups 
"Couchbase Mobile" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/mobile-couchbase/ffeff573-600e-4f8d-bbbd-b6932fde16fd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to