List of usage examples for org.springframework.web.servlet.mvc.method.annotation SseEmitter complete
public synchronized void complete()
From source file:com.bodybuilding.argos.controller.SseEmitterUtil.java
/** * Binds the supplied observable to the SseEmitter. onNext will call the send method on SseEmitter, the Observable * subscription will automatically be cancelled when the emitter completes or times out. * @param emitter SseEmitter// www . j a v a 2 s. co m * @param observable Observable that will supply the data * @return Subscription to the Observable */ public static <T> Subscription bindObservable(SseEmitter emitter, Observable<T> observable) { Subscription subscription = observable.subscribe(new Subscriber<T>() { @Override public void onCompleted() { emitter.complete(); } @Override public void onError(Throwable e) { LOG.warn("Error from stream observable", e); emitter.completeWithError(e); } @Override public void onNext(T t) { emitSse(emitter, t); } }); bindUnsubscribe(emitter, subscription); return subscription; }