java.lang.Runnable, EventSource.Emitterprotected class EventSourceServlet.EventSourceEmitter extends java.lang.Object implements EventSource.Emitter, java.lang.Runnable
| Constructor | Description |
|---|---|
EventSourceEmitter(EventSource eventSource,
AsyncContext async) |
| Modifier and Type | Method | Description |
|---|---|---|
void |
close() |
Closes this event source connection.
|
void |
comment(java.lang.String comment) |
Sends a comment to the client.
|
void |
data(java.lang.String data) |
Sends a default event with data to the client.
|
void |
event(java.lang.String name,
java.lang.String data) |
Sends a named event with data to the client.
|
protected void |
flush() |
|
void |
run() |
public EventSourceEmitter(EventSource eventSource, AsyncContext async) throws java.io.IOException
java.io.IOExceptionpublic void event(java.lang.String name,
java.lang.String data)
throws java.io.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 sentjava.io.IOException - if an I/O failure occurredEventSource.Emitter.data(String)public void data(java.lang.String data)
throws java.io.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 sentjava.io.IOException - if an I/O failure occurredpublic void comment(java.lang.String comment)
throws java.io.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 sendjava.io.IOException - if an I/O failure occurredpublic void run()
run in interface java.lang.Runnableprotected void flush()
throws java.io.IOException
java.io.IOExceptionpublic void close()
EventSource.EmitterCloses this event source connection.
close in interface EventSource.EmitterCopyright © 1995–2018 Webtide. All rights reserved.