Package io.mangoo.services
Class ServerSentEventService
java.lang.Object
io.mangoo.services.ServerSentEventService
- Author:
- svenkubiak
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddConnection(io.undertow.server.handlers.sse.ServerSentEventConnection connection) Adds a new connection to the managervoidCloses all connections for a given URI resourceSet<io.undertow.server.handlers.sse.ServerSentEventConnection>getConnections(String uri) Retrieves all connection resources under a given URLvoidremoveConnections(String uri) Removes all URI resources for a given URLvoidSends data to all connections for a given URI resourcevoidsend(String uri, String data, io.undertow.server.handlers.sse.ServerSentEventConnection.EventCallback eventCallback) Sends data to all connections for a given URI and invokes the callback on Success or failurevoidsetConnections(String uri, Set<io.undertow.server.handlers.sse.ServerSentEventConnection> uriConnections) Sets the URI resources for a given URL
-
Method Details
-
addConnection
public void addConnection(io.undertow.server.handlers.sse.ServerSentEventConnection connection) Adds a new connection to the manager- Parameters:
connection- The connection to put
-
send
Sends data to all connections for a given URI resource- Parameters:
uri- The URI resource for the connectiondata- The event data
-
send
public void send(String uri, String data, io.undertow.server.handlers.sse.ServerSentEventConnection.EventCallback eventCallback) Sends data to all connections for a given URI and invokes the callback on Success or failure- Parameters:
uri- The URI resource for the connectiondata- The event dataeventCallback- A callback that is notified on Success or failure
-
close
Closes all connections for a given URI resource- Parameters:
uri- The URI resource for the connection
-
getConnections
Retrieves all connection resources under a given URL- Parameters:
uri- The URI resource for the connections- Returns:
- A Set of connections for the URI resource
-
setConnections
public void setConnections(String uri, Set<io.undertow.server.handlers.sse.ServerSentEventConnection> uriConnections) Sets the URI resources for a given URL- Parameters:
uri- The URI resource for the connectionuriConnections- The connections for the URI resource
-
removeConnections
Removes all URI resources for a given URL- Parameters:
uri- The URI resource for the connection
-