Class WebsocketConnectionConfig

java.lang.Object
com.github.twitch4j.client.websocket.WebsocketConnectionConfig

public class WebsocketConnectionConfig extends Object
  • Constructor Details

    • WebsocketConnectionConfig

      public WebsocketConnectionConfig()
  • Method Details

    • process

    • validate

      public void validate()
      validate the config
    • baseUrl

      public WebsocketConnectionConfig baseUrl(String baseUrl)
      The websocket url for the chat client to connect to.
      Returns:
      this.
    • wsPingPeriod

      public WebsocketConnectionConfig wsPingPeriod(int wsPingPeriod)
      WebSocket RFC Ping Period in ms (0 = disabled)
      Returns:
      this.
    • connectionTimeout

      public WebsocketConnectionConfig connectionTimeout(int connectionTimeout)
      Websocket timeout milliseconds for establishing a connection (0 = disabled).
      Returns:
      this.
    • socketTimeout

      public WebsocketConnectionConfig socketTimeout(int socketTimeout)
      Websocket timeout milliseconds for read and write operations (0 = disabled).
      Returns:
      this.
    • closeDelay

      public WebsocketConnectionConfig 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.

      This can be set as low as 0 for applications that require prompt socket closes upon disconnect calls.

      Returns:
      this.
    • headers

      public WebsocketConnectionConfig headers(Map<String,String> headers)
      WebSocket Headers
      Returns:
      this.
    • taskExecutor

      public WebsocketConnectionConfig taskExecutor(ScheduledExecutorService taskExecutor)
      Task Executor
      Returns:
      this.
    • backoffStrategy

      public WebsocketConnectionConfig backoffStrategy(IBackoffStrategy backoffStrategy)
      Helper class to compute delays between connection retries
      Returns:
      this.
    • onStateChanged

      called when the websocket's state changes
      Returns:
      this.
    • onPreConnect

      public WebsocketConnectionConfig onPreConnect(Runnable onPreConnect)
      called before connecting
      Returns:
      this.
    • onPostConnect

      public WebsocketConnectionConfig onPostConnect(Runnable onPostConnect)
      called after connecting
      Returns:
      this.
    • onConnected

      public WebsocketConnectionConfig onConnected(Runnable onConnected)
      called after the connection to the websocket server has been established successfully
      Returns:
      this.
    • onTextMessage

      public WebsocketConnectionConfig onTextMessage(Consumer<String> onTextMessage)
      called when receiving a text message on from the websocket server
      Returns:
      this.
    • onDisconnecting

      public WebsocketConnectionConfig onDisconnecting(Runnable onDisconnecting)
      called when connection state is changing from CONNECTED to DISCONNECTING
      Returns:
      this.
    • onPreDisconnect

      public WebsocketConnectionConfig onPreDisconnect(Runnable onPreDisconnect)
      called before the disconnect

      this occurs after onDisconnecting and before the connection is disposed

      Returns:
      this.
    • onPostDisconnect

      public WebsocketConnectionConfig onPostDisconnect(Runnable 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

      public WebsocketConnectionConfig proxyConfig(ProxyConfig proxyConfig)
      proxy config
      Returns:
      this.
    • baseUrl

      public String 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

      public Map<String,String> headers()
      WebSocket Headers
    • taskExecutor

      public ScheduledExecutorService taskExecutor()
      Task Executor
    • backoffStrategy

      public IBackoffStrategy backoffStrategy()
      Helper class to compute delays between connection retries
    • onStateChanged

      called when the websocket's state changes
    • onPreConnect

      public Runnable onPreConnect()
      called before connecting
    • onPostConnect

      public Runnable onPostConnect()
      called after connecting
    • onConnected

      public Runnable onConnected()
      called after the connection to the websocket server has been established successfully
    • onTextMessage

      public Consumer<String> onTextMessage()
      called when receiving a text message on from the websocket server
    • onDisconnecting

      public Runnable onDisconnecting()
      called when connection state is changing from CONNECTED to DISCONNECTING
    • onPreDisconnect

      public Runnable onPreDisconnect()
      called before the disconnect

      this occurs after onDisconnecting and before the connection is disposed

    • onPostDisconnect

      public Runnable onPostDisconnect()
      called after the disconnect
    • onCloseFrame

      public BiConsumer<@NotNull Integer,@Nullable String> onCloseFrame()
      called after receiving a close frame from the server
    • proxyConfig

      public ProxyConfig proxyConfig()
      proxy config