return Observable.interval(interval, TimeUnit.MILLISECONDS)
.flatMap(new Func1<Long, Observable<Void>>() {
@Override
public Observable<Void> call(Long interval) {
System.out.println("Writing SSE event for interval: " + interval);
return response.writeAndFlush(new ServerSentEvent(String.valueOf(interval), "notification", "hello " + interval));
}
}).materialize()
.takeWhile(new Func1<Notification<Void>, Boolean>() {
@Override
public Boolean call(Notification<Void> notification) {