Skip to content

Instantly share code, notes, and snippets.

@ricdex
Created March 28, 2016 20:16
Show Gist options
  • Save ricdex/fa9c8c6749f140d75b44 to your computer and use it in GitHub Desktop.
Save ricdex/fa9c8c6749f140d75b44 to your computer and use it in GitHub Desktop.
SSEmiter con Android
private void startClient() throws InterruptedException {
EventSource es = new EventSource(URI.create("http://192.168.1.43:8080/helloCount"), new EventSourceHandler() {
@Override
public void onConnect() {
System.out.println("CONNECTED");
}
@Override
public void onMessage(String event, MessageEvent message) {
System.out.println("event = " + event + ", message = " + message);
}
@Override
public void onError(Throwable t) {
System.err.println("ERROR");
t.printStackTrace();
}
});
es.connect();
new CountDownLatch(1).await();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment