Package org.eclipse.jetty.servlets
Class EventSourceServlet.EventSourceEmitter
- java.lang.Object
-
- org.eclipse.jetty.servlets.EventSourceServlet.EventSourceEmitter
-
- All Implemented Interfaces:
Runnable,EventSource.Emitter
- Enclosing class:
- EventSourceServlet
protected class EventSourceServlet.EventSourceEmitter extends Object implements EventSource.Emitter, Runnable
-
-
Constructor Summary
Constructors Constructor Description EventSourceEmitter(EventSource eventSource, AsyncContext async)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes this event source connection.voidcomment(String comment)Sends a comment to the client.voiddata(String data)Sends a default event with data to the client.voidevent(String name, String data)Sends a named event with data to the client.protected voidflush()voidrun()
-
-
-
Constructor Detail
-
EventSourceEmitter
public EventSourceEmitter(EventSource eventSource, AsyncContext async) throws IOException
- Throws:
IOException
-
-
Method Detail
-
event
public void event(String name, String data) throws IOException
Description copied from interface:EventSource.EmitterSends 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:
eventin interfaceEventSource.Emitter- Parameters:
name- the event namedata- the data to be sent- Throws:
IOException- if an I/O failure occurred- See Also:
EventSource.Emitter.data(String)
-
data
public void data(String data) throws IOException
Description copied from interface:EventSource.EmitterSends 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:
datain interfaceEventSource.Emitter- Parameters:
data- the data to be sent- Throws:
IOException- if an I/O failure occurred
-
comment
public void comment(String comment) throws IOException
Description copied from interface:EventSource.EmitterSends a comment to the client.
When invoked as:
comment("foo"), the client will receive the line:: foo
- Specified by:
commentin interfaceEventSource.Emitter- Parameters:
comment- the comment to send- Throws:
IOException- if an I/O failure occurred
-
flush
protected void flush() throws IOException- Throws:
IOException
-
close
public void close()
Description copied from interface:EventSource.EmitterCloses this event source connection.
- Specified by:
closein interfaceEventSource.Emitter
-
-