Package com.kristensoft.kdc
Class TcpClientParameters.Builder
- java.lang.Object
-
- com.kristensoft.kdc.Parameters.Builder<T>
-
- com.kristensoft.kdc.ClientParameters.Builder<TcpClientParameters.Builder>
-
- com.kristensoft.kdc.TcpClientParameters.Builder
-
- Enclosing class:
- TcpClientParameters
public static class TcpClientParameters.Builder extends ClientParameters.Builder<TcpClientParameters.Builder>
BuildsTcpClientParametersinstances.The builder provides TCP-specific configuration for connection behavior, automatic reconnection, socket options, and event handlers, in addition to the common client configuration inherited from
ClientParameters.Builder.Unless explicitly configured, values are initialized using the applicable KDC defaults.
- See Also:
TcpClientParameters,ClientParameters.Builder
-
-
Constructor Summary
Constructors Constructor Description Builder()Creates a builder for configuring TCP client parameters.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TcpClientParameters.BuilderaddEventHandler(TcpClientEventHandler handler)Adds a TCP client event handler to this configuration.TcpClientParameters.BuilderaddEventHandlers(List<TcpClientEventHandler> handlers)Adds the specified TCP client event handlers to this configuration.TcpClientParametersbuild()Builds aTcpClientParametersinstance using the current builder configuration.TcpClientParameters.BuilderwithAutoReconnect(boolean autoReconnect)Sets whether the TCP client automatically attempts to reconnect when its connection is lost.TcpClientParameters.BuilderwithConnectionTimeout(int connectionTimeout)Sets the amount of time allowed for establishing a TCP connection.TcpClientParameters.BuilderwithEventHandlers(List<TcpClientEventHandler> handlers)Replaces the TCP client event handlers in this configuration with the specified handlers.TcpClientParameters.BuilderwithReconnectDelay(int reconnectDelay)Sets the amount of time to wait between TCP reconnection attempts.TcpClientParameters.BuilderwithSocketOptions(TcpClientSocketOptions options)Sets the socket options used to configure the TCP client's socket.-
Methods inherited from class com.kristensoft.kdc.ClientParameters.Builder
withRemoteAddress, withRemoteAddress, withRemoteAddress, withRemoteAddress, withSendSyncTimeout
-
Methods inherited from class com.kristensoft.kdc.Parameters.Builder
addWhiteListEntry, registerApi, registerApi, registerApis, withAutoStart, withBindAddress, withBindAddress, withBindAddress, withCompressed, withConnectionQueuePoolSize, withCrc, withEncryptionKey, withLatencyMode, withLatencyReportingInterval, withMaxReceivedBufferSize, withMaxSendBufferSize, withSerializationFormat, withWhiteList
-
-
-
-
Method Detail
-
withSocketOptions
public TcpClientParameters.Builder withSocketOptions(TcpClientSocketOptions options)
Sets the socket options used to configure the TCP client's socket.- Parameters:
options- the TCP client socket options- Returns:
- this builder
- Throws:
IllegalArgumentException- ifoptionsisnull
-
withAutoReconnect
public TcpClientParameters.Builder withAutoReconnect(boolean autoReconnect)
Sets whether the TCP client automatically attempts to reconnect when its connection is lost.- Parameters:
autoReconnect-trueto enable automatic reconnection;falseotherwise- Returns:
- this builder
-
withConnectionTimeout
public TcpClientParameters.Builder withConnectionTimeout(int connectionTimeout)
Sets the amount of time allowed for establishing a TCP connection.- Parameters:
connectionTimeout- the connection timeout in milliseconds- Returns:
- this builder
- Throws:
IllegalArgumentException- ifconnectionTimeoutis negative
-
withReconnectDelay
public TcpClientParameters.Builder withReconnectDelay(int reconnectDelay)
Sets the amount of time to wait between TCP reconnection attempts.- Parameters:
reconnectDelay- the reconnect delay in milliseconds- Returns:
- this builder
- Throws:
IllegalArgumentException- ifreconnectDelayis negative
-
addEventHandler
public TcpClientParameters.Builder addEventHandler(TcpClientEventHandler handler)
Adds a TCP client event handler to this configuration.- Parameters:
handler- the TCP client event handler to add- Returns:
- this builder
- Throws:
IllegalArgumentException- ifhandlerisnull
-
withEventHandlers
public TcpClientParameters.Builder withEventHandlers(List<TcpClientEventHandler> handlers)
Replaces the TCP client event handlers in this configuration with the specified handlers.- Parameters:
handlers- the TCP client event handlers to use- Returns:
- this builder
- Throws:
IllegalArgumentException- ifhandlersisnullor contains anullhandler
-
addEventHandlers
public TcpClientParameters.Builder addEventHandlers(List<TcpClientEventHandler> handlers)
Adds the specified TCP client event handlers to this configuration.- Parameters:
handlers- the TCP client event handlers to add- Returns:
- this builder
- Throws:
IllegalArgumentException- ifhandlersisnullor contains anullhandler
-
build
public TcpClientParameters build()
Builds aTcpClientParametersinstance using the current builder configuration.- Specified by:
buildin classClientParameters.Builder<TcpClientParameters.Builder>- Returns:
- the configured TCP client parameters
-
-