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
IOException
public void event(String name, String data) throws IOException
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
event
in interface EventSource.Emitter
name
- 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.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
data
in interface EventSource.Emitter
data
- the data to be sentIOException
- if an I/O failure occurredpublic void comment(String comment) throws IOException
EventSource.Emitter
Sends a comment to the client.
When invoked as: comment("foo")
, the client will receive the line:
: foo
comment
in interface EventSource.Emitter
comment
- the comment to sendIOException
- if an I/O failure occurredprotected void flush() throws IOException
IOException
public void close()
EventSource.Emitter
Closes this event source connection.
close
in interface EventSource.Emitter
Copyright © 1995-2015 Webtide. All Rights Reserved.