Package io.mangoo.services
Class ServerSentEventService
- java.lang.Object
-
- io.mangoo.services.ServerSentEventService
-
public class ServerSentEventService extends Object
- Author:
- svenkubiak
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddConnection(io.undertow.server.handlers.sse.ServerSentEventConnection connection)Adds a new connection to the managervoidclose(String uri)Closes 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 URLvoidsend(String uri, String data)Sends 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 Detail
-
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
public void send(String uri, String data)
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
public void close(String uri)
Closes all connections for a given URI resource- Parameters:
uri- The URI resource for the connection
-
getConnections
public Set<io.undertow.server.handlers.sse.ServerSentEventConnection> getConnections(String uri)
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
public void removeConnections(String uri)
Removes all URI resources for a given URL- Parameters:
uri- The URI resource for the connection
-
-