Package org.eclipse.jetty.ee10.servlets
Class EventSourceServlet.EventSourceEmitter
java.lang.Object
org.eclipse.jetty.ee10.servlets.EventSourceServlet.EventSourceEmitter
- All Implemented Interfaces:
Runnable
,EventSource.Emitter
- Enclosing class:
- EventSourceServlet
protected class EventSourceServlet.EventSourceEmitter
extends Object
implements EventSource.Emitter, Runnable
-
Constructor Summary
ConstructorDescriptionEventSourceEmitter
(EventSource eventSource, jakarta.servlet.AsyncContext async) -
Method Summary
-
Constructor Details
-
EventSourceEmitter
public EventSourceEmitter(EventSource eventSource, jakarta.servlet.AsyncContext async) throws IOException - Throws:
IOException
-
-
Method Details
-
event
Description copied from interface:EventSource.Emitter
Sends a named event with data to the client.
When invoked as:
event("foo", "bar")
, the client will receive the lines:event: foo data: bar
- Specified by:
event
in interfaceEventSource.Emitter
- Parameters:
name
- the event namedata
- the data to be sent- Throws:
IOException
- if an I/O failure occurred- See Also:
-
data
Description copied from interface:EventSource.Emitter
Sends a default event with data to the client.
When invoked as:
data("baz")
, the client will receive the line:data: baz
When invoked as:
data("foo\r\nbar\rbaz\nbax")
, the client will receive the lines:data: foo data: bar data: baz data: bax
- Specified by:
data
in interfaceEventSource.Emitter
- Parameters:
data
- the data to be sent- Throws:
IOException
- if an I/O failure occurred
-
comment
Description copied from interface:EventSource.Emitter
Sends a comment to the client.
When invoked as:
comment("foo")
, the client will receive the line:: foo
- Specified by:
comment
in interfaceEventSource.Emitter
- Parameters:
comment
- the comment to send- Throws:
IOException
- if an I/O failure occurred
-
run
public void run() -
flush
- Throws:
IOException
-
close
public void close()Description copied from interface:EventSource.Emitter
Closes this event source connection.
- Specified by:
close
in interfaceEventSource.Emitter
-