Touchkit - Calling Geolocator.detect method many times.

Hi,

I want to call Geolocator.detect method many times. But I can’t.
I create an instance of a thread for call it in every 5000 miliseconds( Thread.sleep(5000) ). But the detect method doesn’t step into onSuccess or onFailure methods.

Here is the code below.

import com.vaadin.addon.touchkit.extensions.Geolocator;
import com.vaadin.addon.touchkit.extensions.PositionCallback;
import com.vaadin.addon.touchkit.gwt.client.vcom.Position;
import com.vaadin.addon.touchkit.ui.NavigationView;
import com.vaadin.ui.UI;

public class Locator extends NavigationView {

private static final long serialVersionUID = -4674692947624699697L;
private Worker worker;

public Locator() {
    
    setCaption("Locator");
    worker = new Worker();
    worker.start();
}

public class Worker extends Thread{

    private void sleep(){
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            System.out.println(e.getMessage());
        }
    }
    
    private void callPosition()
    {
        Geolocator.detect(new PositionCallback() {
            
            @Override
            public void onSuccess(Position position) {
                System.out.println(position);
            }
            
            @Override
            public void onFailure(int errorCode) {
                System.out.println(errorCode);
            }
        });    
    }
    
    @Override
    public void run() {
        
        synchronized (UI.getCurrent()) {
            while (true) {
                sleep();
                callPosition();
            }    
        }
    }
    
}

}

Thanks for replies.

Just to make sure, you have enabled server push, right?

Access to a UI should synchronized on the session,
as described here
, not the UI.

At First, Thanks for reply.

I solved that with
refresher
addon. I think it pushes the data to client.

What’s your idea? Refresher is better or your solution is better?

What do you suggest?

Thanks.

Hi,

Refresher uses polling, not pushing, but you can do what you want also with that.