Class HandshakeResult.Accepted.Builder
java.lang.Object
com.soklet.HandshakeResult.Accepted.Builder
- Enclosing class:
HandshakeResult.Accepted
Builder used to construct instances of
HandshakeResult.Accepted.
This class is intended for use by a single thread.
- Author:
- Mark Allen
-
Method Summary
Modifier and TypeMethodDescriptionbuild()clientContext(@Nullable Object clientContext) Specifies an application-specific custom context to be preserved over the lifetime of the SSE connection.clientInitializer(@Nullable Consumer<ServerSentEventUnicaster> clientInitializer) Specifies custom "client initializer" function to run immediately after the handshake succeeds - useful for performing "catch-up" logic if the client had provided aLast-Event-IDrequest header.cookies(@Nullable Set<@NonNull ResponseCookie> cookies) Specifies custom response cookies to be sent with the handshake.Specifies custom response headers to be sent with the handshake.
-
Method Details
-
headers
-
cookies
public @NonNull HandshakeResult.Accepted.Builder cookies(@Nullable Set<@NonNull ResponseCookie> cookies) Specifies custom response cookies to be sent with the handshake.- Parameters:
cookies- custom response cookies to send- Returns:
- this builder, for chaining
-
clientContext
Specifies an application-specific custom context to be preserved over the lifetime of the SSE connection.For example, an application might want to broadcast differently-formatted payloads based on the client's locale - a
Localeobject could be specified as client context.Server-Sent Events can then be broadcast per-locale via
ServerSentEventBroadcaster.broadcastEvent(Function, Function).- Parameters:
clientContext- custom context- Returns:
- this builder, for chaining
-
clientInitializer
public @NonNull HandshakeResult.Accepted.Builder clientInitializer(@Nullable Consumer<ServerSentEventUnicaster> clientInitializer) Specifies custom "client initializer" function to run immediately after the handshake succeeds - useful for performing "catch-up" logic if the client had provided aLast-Event-IDrequest header.The function is provided with a
ServerSentEventUnicaster, which permits sending Server-Sent Events and comments directly to the client that accepted the handshake (as opposed to aServerSentEventBroadcaster, which would send to all clients listening on the sameResourcePath).Full documentation is available at https://www.soklet.com/docs/server-sent-events.
- Parameters:
clientInitializer- custom function to run to initialize the client- Returns:
- this builder, for chaining
-
build
-