public class SseEjector extends Object
SseEjector sseEjector = new SseEjector(context);
sseEjector.send(SseEventSource.builder().data("{\"code\":200}"));
return sseEjector;
if you prefer to keep emitter for a while, you should use
sseEjector.keepAlive(3600); // retain emitter for 1 hour / 3600 seconds.
if emitter is still alive, and you want to stop it directly, try
sseEjector.complete();
| Modifier and Type | Field and Description |
|---|---|
protected org.flmelody.core.sse.SseEjector.EjectorCallback |
callback |
protected AtomicBoolean |
complete |
protected AtomicLong |
timeout |
| Constructor and Description |
|---|
SseEjector(SseWindwardContext sseWindwardContext) |
| Modifier and Type | Method and Description |
|---|---|
void |
complete()
Complete ejector, after this, you can't send data to client anymore
|
protected org.flmelody.core.sse.SseEjector.EjectorCallback |
getCallback() |
protected long |
getTimeout() |
SseEjector |
keepAlive(Long seconds)
Retain Ejector for the specified number of seconds, if you do not set the time the default will
end directly.
|
void |
send(SseEventSource.SseEventSourceBuilder builder) |
protected final AtomicBoolean complete
protected final AtomicLong timeout
protected final org.flmelody.core.sse.SseEjector.EjectorCallback callback
public SseEjector(SseWindwardContext sseWindwardContext)
public void send(SseEventSource.SseEventSourceBuilder builder)
public SseEjector keepAlive(Long seconds)
seconds - time for ejector to liveprotected long getTimeout()
protected org.flmelody.core.sse.SseEjector.EjectorCallback getCallback()
public void complete()
Copyright © 2024 flmelody. All rights reserved.