Class DefaultServerSentEventServer
java.lang.Object
com.soklet.core.impl.DefaultServerSentEventServer
- All Implemented Interfaces:
ServerSentEventServer,AutoCloseable
@ThreadSafe
public class DefaultServerSentEventServer
extends Object
implements ServerSentEventServer
- Author:
- Mark Allen
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder used to construct instances ofDefaultServerSentEventServer.Nested classes/interfaces inherited from interface com.soklet.core.ServerSentEventServer
ServerSentEventServer.RequestHandler -
Method Summary
Modifier and TypeMethodDescriptionOptional<? extends ServerSentEventBroadcaster> acquireBroadcaster(ResourcePath resourcePath) Given aResourcePaththat corresponds to a Resource Method annotated withServerSentEventSource, acquire aServerSentEventBroadcasterwhich is capable of "pushing" messages to all connected Server-Sent Event clients.voidinitialize(SokletConfiguration sokletConfiguration, ServerSentEventServer.RequestHandler requestHandler) TheSokletinstance which manages thisServerSentEventServerwill invoke this method exactly once at initialization time - this allowsSokletto "talk" to yourServerSentEventServer.Is this SSE server started (that is, able to handle requests from clients)?voidstart()Starts the SSE server, which makes it able to accept requests from clients.voidstop()Stops the SSE server, which makes it unable to accept requests from clients.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.soklet.core.ServerSentEventServer
close
-
Method Details
-
withPort
-
initialize
public void initialize(@Nonnull SokletConfiguration sokletConfiguration, @Nonnull ServerSentEventServer.RequestHandler requestHandler) Description copied from interface:ServerSentEventServerTheSokletinstance which manages thisServerSentEventServerwill invoke this method exactly once at initialization time - this allowsSokletto "talk" to yourServerSentEventServer.This method is designed for internal use by
Sokletonly and should not be invoked elsewhere.- Specified by:
initializein interfaceServerSentEventServer- Parameters:
sokletConfiguration- configuration for the Soklet instance that controls this serverrequestHandler- aSoklet-internal request handler which takes aServerSentEventServer-provided request as input and supplies aMarshaledResponseas output for theServerSentEventServerto write back to the client
-
start
Description copied from interface:ServerSentEventServerStarts the SSE server, which makes it able to accept requests from clients.If the server is already started, no action is taken.
This method is designed for internal use by
Sokletonly and should not be invoked elsewhere.- Specified by:
startin interfaceServerSentEventServer
-
stop
Description copied from interface:ServerSentEventServerStops the SSE server, which makes it unable to accept requests from clients.If the server is already stopped, no action is taken.
This method is designed for internal use by
Sokletonly and should not be invoked elsewhere.- Specified by:
stopin interfaceServerSentEventServer
-
isStarted
Description copied from interface:ServerSentEventServerIs this SSE server started (that is, able to handle requests from clients)?- Specified by:
isStartedin interfaceServerSentEventServer- Returns:
trueif the server is started,falseotherwise
-
acquireBroadcaster
@Nonnull public Optional<? extends ServerSentEventBroadcaster> acquireBroadcaster(@Nullable ResourcePath resourcePath) Description copied from interface:ServerSentEventServerGiven aResourcePaththat corresponds to a Resource Method annotated withServerSentEventSource, acquire aServerSentEventBroadcasterwhich is capable of "pushing" messages to all connected Server-Sent Event clients.Soklet guarantees exactly one
ServerSentEventBroadcasterinstance exists perResourcePath. Soklet is responsible for the creation and management ofServerSentEventBroadcasterinstances.See https://www.soklet.com/docs/server-sent-events for detailed documentation.
- Specified by:
acquireBroadcasterin interfaceServerSentEventServer- Parameters:
resourcePath- theServerSentEventSource-annotated Resource Method for which to acquire a broadcaster- Returns:
- a broadcaster for the given
ResourcePath, orOptional.empty()if there is no broadcaster available
-
getResourceMethodsByResourcePathDeclaration
-