Class WebsocketConnectionConfig
java.lang.Object
com.github.twitch4j.client.websocket.WebsocketConnectionConfig
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionHelper class to compute delays between connection retriesbackoffStrategy
(IBackoffStrategy backoffStrategy) Helper class to compute delays between connection retriesbaseUrl()
The websocket url for the chat client to connect to.The websocket url for the chat client to connect to.int
The maximum number of milliseconds to wait after sending a close frame to receive confirmation from the server, before fully closing the socket.closeDelay
(int closeDelay) The maximum number of milliseconds to wait after sending a close frame to receive confirmation from the server, before fully closing the socket.int
Websocket timeout milliseconds for establishing a connection (0 = disabled).connectionTimeout
(int connectionTimeout) Websocket timeout milliseconds for establishing a connection (0 = disabled).headers()
WebSocket HeadersWebSocket HeadersBiConsumer<@NotNull Integer,
@Nullable String> called after receiving a close frame from the serveronCloseFrame
(BiConsumer<@NotNull Integer, @Nullable String> onCloseFrame) called after receiving a close frame from the servercalled after the connection to the websocket server has been established successfullyonConnected
(Runnable onConnected) called after the connection to the websocket server has been established successfullycalled when connection state is changing from CONNECTED to DISCONNECTINGonDisconnecting
(Runnable onDisconnecting) called when connection state is changing from CONNECTED to DISCONNECTINGcalled after connectingonPostConnect
(Runnable onPostConnect) called after connectingcalled after the disconnectonPostDisconnect
(Runnable onPostDisconnect) called after the disconnectcalled before connectingonPreConnect
(Runnable onPreConnect) called before connectingcalled before the disconnectonPreDisconnect
(Runnable onPreDisconnect) called before the disconnectcalled when the websocket's state changesonStateChanged
(BiConsumer<WebsocketConnectionState, WebsocketConnectionState> onStateChanged) called when the websocket's state changescalled when receiving a text message on from the websocket serveronTextMessage
(Consumer<String> onTextMessage) called when receiving a text message on from the websocket serverstatic WebsocketConnectionConfig
proxy configproxyConfig
(ProxyConfig proxyConfig) proxy configint
Websocket timeout milliseconds for read and write operations (0 = disabled).socketTimeout
(int socketTimeout) Websocket timeout milliseconds for read and write operations (0 = disabled).Task ExecutortaskExecutor
(ScheduledExecutorService taskExecutor) Task Executorvoid
validate()
validate the configint
WebSocket RFC Ping Period in ms (0 = disabled)wsPingPeriod
(int wsPingPeriod) WebSocket RFC Ping Period in ms (0 = disabled)
-
Constructor Details
-
WebsocketConnectionConfig
public WebsocketConnectionConfig()
-
-
Method Details
-
process
-
validate
public void validate()validate the config -
baseUrl
The websocket url for the chat client to connect to.- Returns:
this
.
-
wsPingPeriod
WebSocket RFC Ping Period in ms (0 = disabled)- Returns:
this
.
-
connectionTimeout
Websocket timeout milliseconds for establishing a connection (0 = disabled).- Returns:
this
.
-
socketTimeout
Websocket timeout milliseconds for read and write operations (0 = disabled).- Returns:
this
.
-
closeDelay
The maximum number of milliseconds to wait after sending a close frame to receive confirmation from the server, before fully closing the socket.This can be set as low as 0 for applications that require prompt socket closes upon disconnect calls.
- Returns:
this
.
-
headers
WebSocket Headers- Returns:
this
.
-
taskExecutor
Task Executor- Returns:
this
.
-
backoffStrategy
Helper class to compute delays between connection retries- Returns:
this
.
-
onStateChanged
public WebsocketConnectionConfig onStateChanged(BiConsumer<WebsocketConnectionState, WebsocketConnectionState> onStateChanged) called when the websocket's state changes- Returns:
this
.
-
onPreConnect
called before connecting- Returns:
this
.
-
onPostConnect
called after connecting- Returns:
this
.
-
onConnected
called after the connection to the websocket server has been established successfully- Returns:
this
.
-
onTextMessage
called when receiving a text message on from the websocket server- Returns:
this
.
-
onDisconnecting
called when connection state is changing from CONNECTED to DISCONNECTING- Returns:
this
.
-
onPreDisconnect
called before the disconnectthis occurs after onDisconnecting and before the connection is disposed
- Returns:
this
.
-
onPostDisconnect
called after the disconnect- Returns:
this
.
-
onCloseFrame
public WebsocketConnectionConfig onCloseFrame(BiConsumer<@NotNull Integer, @Nullable String> onCloseFrame) called after receiving a close frame from the server- Returns:
this
.
-
proxyConfig
proxy config- Returns:
this
.
-
baseUrl
The websocket url for the chat client to connect to. -
wsPingPeriod
public int wsPingPeriod()WebSocket RFC Ping Period in ms (0 = disabled) -
connectionTimeout
public int connectionTimeout()Websocket timeout milliseconds for establishing a connection (0 = disabled). -
socketTimeout
public int socketTimeout()Websocket timeout milliseconds for read and write operations (0 = disabled). -
closeDelay
public int closeDelay()The maximum number of milliseconds to wait after sending a close frame to receive confirmation from the server, before fully closing the socket.This can be set as low as 0 for applications that require prompt socket closes upon disconnect calls.
-
headers
WebSocket Headers -
taskExecutor
Task Executor -
backoffStrategy
Helper class to compute delays between connection retries -
onStateChanged
called when the websocket's state changes -
onPreConnect
called before connecting -
onPostConnect
called after connecting -
onConnected
called after the connection to the websocket server has been established successfully -
onTextMessage
called when receiving a text message on from the websocket server -
onDisconnecting
called when connection state is changing from CONNECTED to DISCONNECTING -
onPreDisconnect
called before the disconnectthis occurs after onDisconnecting and before the connection is disposed
-
onPostDisconnect
called after the disconnect -
onCloseFrame
called after receiving a close frame from the server -
proxyConfig
proxy config
-