Interface EventSource.Emitter
-
- All Known Implementing Classes:
EventSourceServlet.EventSourceEmitter
- Enclosing interface:
- EventSource
public static interface EventSource.EmitterEventSource.Emitteris the active half of an event source connection, and allows applications to operate on the connection by sending events, data or comments, or by closing the connection.An
EventSource.Emitterinstance will be created for each new event source connection.EventSource.Emitterinstances are fully thread safe and can be used from multiple threads.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidclose()Closes this event source connection.voidcomment(java.lang.String comment)Sends a comment to the client.voiddata(java.lang.String data)Sends a default event with data to the client.voidevent(java.lang.String name, java.lang.String data)Sends a named event with data to the client.
-
-
-
Method Detail
-
event
void event(java.lang.String name, java.lang.String data) throws java.io.IOExceptionSends a named event with data to the client.
When invoked as:
event("foo", "bar"), the client will receive the lines:event: foo data: bar
- Parameters:
name- the event namedata- the data to be sent- Throws:
java.io.IOException- if an I/O failure occurred- See Also:
data(String)
-
data
void data(java.lang.String data) throws java.io.IOException
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
- Parameters:
data- the data to be sent- Throws:
java.io.IOException- if an I/O failure occurred
-
comment
void comment(java.lang.String comment) throws java.io.IOExceptionSends a comment to the client.
When invoked as:
comment("foo"), the client will receive the line:: foo
- Parameters:
comment- the comment to send- Throws:
java.io.IOException- if an I/O failure occurred
-
close
void close()
Closes this event source connection.
-
-