WebsockexNova.Defaults.DefaultConnectionHandler (WebsockexNova v0.1.0)

View Source

Default implementation of the ConnectionHandler behavior.

This module provides sensible default implementations for all ConnectionHandler callbacks, including:

  • Basic connection tracking
  • Automatic ping/pong handling
  • Reconnection attempt management
  • Connection state maintenance

Usage

You can use this module directly or as a starting point for your own implementation:

defmodule MyApp.CustomHandler do
  use WebsockexNova.Defaults.DefaultConnectionHandler

  # Override specific callbacks as needed
  def handle_frame(:text, frame_data, conn) do
    # Custom text frame handling
    {:ok, conn}
  end
end

Configuration

The default handler supports the following configuration in the adapter_state:

  • :max_reconnect_attempts - Maximum number of reconnection attempts (default: 5)
  • :reconnect_attempts - Current number of reconnection attempts (default: 0)
  • :ping_interval - Interval in milliseconds between ping frames (default: 30000)

Summary

Functions

Initializes the handler state as a ClientConn struct. Any unknown fields are placed in adapter_state.

Functions

init(opts)

Initializes the handler state as a ClientConn struct. Any unknown fields are placed in adapter_state.