protected class EventSourceServlet.EventSourceEmitter extends Object implements EventSource.Emitter, Runnable
| Constructor and Description |
|---|
EventSourceServlet.EventSourceEmitter(EventSource eventSource,
AsyncContext async) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes this event source connection.
|
void |
comment(String comment)
Sends a comment to the client.
|
void |
data(String data)
Sends a default event with data to the client.
|
void |
event(String name,
String data)
Sends a named event with data to the client.
|
protected void |
flush() |
void |
run() |
public EventSourceServlet.EventSourceEmitter(EventSource eventSource, AsyncContext async) throws IOException
IOExceptionpublic void event(String name, String data) throws IOException
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
event in interface EventSource.Emittername - the event namedata - the data to be sentIOException - if an I/O failure occurredEventSource.Emitter.data(String)public void data(String data) throws IOException
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
data in interface EventSource.Emitterdata - the data to be sentIOException - if an I/O failure occurredpublic void comment(String comment) throws IOException
EventSource.EmitterSends a comment to the client.
When invoked as: comment("foo"), the client will receive the line:
: foo
comment in interface EventSource.Emittercomment - the comment to sendIOException - if an I/O failure occurredprotected void flush()
throws IOException
IOExceptionpublic void close()
EventSource.EmitterCloses this event source connection.
close in interface EventSource.EmitterCopyright © 1995-2015 Webtide. All Rights Reserved.