Я хочу продолжать получать сообщения через Emitter.io, не закрывая соединение.
Вот пример кода:
final FutureConnection connection
= Emitter.getDefault().futureConnection();
// Connects asynchronously to the service
connection.connect().then(new Callback<Void>(){
// We've successfully connected
public void onSuccess(Void value) {
// Create a topic to subscribe to
final Topic t = new Topic(key, "hello");
// Subscribe to the topic
connection.subscribe(t);
// Receives a message asynchronously
connection.receive().then(new Callback<Message>() {
// We've successfully received a message
public void onSuccess(Message msg) {
// Print it out
System.out.println(msg.getPayloadBuffer());
}
// Occurs if a receive operation fails
public void onFailure(Throwable value) { }
});
}
// Occurs if the connect operation fails
public void onFailure(Throwable value) { }
});
А как этого добиться?