- java.lang.Object
-
- com.kttdevelopment.simplehttpserver.handler.SSEHandler
-
- All Implemented Interfaces:
SimpleHttpHandler,HttpHandler
public class SSEHandler extends Object implements SimpleHttpHandler
A SSE handler allows server to client events by using antext/event-stream. Events are sent usingpush(String)orpush(String, int, String).- Since:
- 03.01.00
- Version:
- 03.05.00
- Author:
- Ktt Development
- See Also:
SimpleHttpHandler
-
-
Constructor Summary
Constructors Constructor Description SSEHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidhandle(SimpleHttpExchange exchange)Handlers the given request and generates a response if no exceptions occur.voidhandle(HttpExchange exchange)Encapsulates theSimpleHttpHandler.handle(SimpleHttpExchange)for the authenticator.voidpush(String data)Pushes an event to the stream.voidpush(String data, int retry, String event)Pushes an event to the stream.StringtoString()
-
-
-
Method Detail
-
handle
public final void handle(HttpExchange exchange) throws IOException
Description copied from interface:SimpleHttpHandlerEncapsulates theSimpleHttpHandler.handle(SimpleHttpExchange)for the authenticator. This method is reserved by the server; do not override this, it will break theSimpleHttpHandler.handle(SimpleHttpExchange)method.- Specified by:
handlein interfaceHttpHandler- Specified by:
handlein interfaceSimpleHttpHandler- Parameters:
exchange- client information- Throws:
IOException- internal failure
-
handle
public final void handle(SimpleHttpExchange exchange) throws IOException
Description copied from interface:SimpleHttpHandlerHandlers the given request and generates a response if no exceptions occur.- Specified by:
handlein interfaceSimpleHttpHandler- Parameters:
exchange- client information- Throws:
IOException- internal failure
-
push
public final void push(String data)
Pushes an event to the stream.- Parameters:
data- data to send- Since:
- 03.01.00
- See Also:
push(String, int, String)
-
push
public final void push(String data, int retry, String event)
Pushes an event to the stream.- Parameters:
data- data to sendretry- how long to retry forevent- event type- Since:
- 03.01.00
- See Also:
push(String)
-
-